Data and Math

vgeometry

Flat 2D geometry: distances, polygon areas, convex hulls and segment crossings.

Released v1.0.0 · 2026-09-28
Import
use "stdlib/geometry.ven"
vgeometry.ven
print distance((0.0, 0.0), (3.0, 4.0))
:: 5.0
Reference (11 functions)

API reference

distance(a, b)

Gives back the straight line distance between two points.

distance((0.0, 0.0), (3.0, 4.0))
:: 5.0

polygon_signed_area_x2(points)

Gives back twice the signed area of a polygon.

polygon_signed_area_x2([(0.0, 0.0), (4.0, 0.0), (4.0, 3.0), (0.0, 3.0)])
:: 24.0

polygon_area(points)

Gives back the area enclosed by a polygon.

polygon_area([(0.0, 0.0), (4.0, 0.0), (4.0, 3.0), (0.0, 3.0)])
:: 12.0

polygon_perimeter(points)

Gives back the total length of a polygon's boundary.

polygon_perimeter([(0.0, 0.0), (4.0, 0.0), (4.0, 3.0), (0.0, 3.0)])
:: 14.0

centroid(points)

Gives back a polygon's area-weighted centroid.

centroid([(0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 1.0)])
:: (0.5, 0.5)

bounding_box(points)

Gives back the axis-aligned bounding box of a set of points.

bounding_box([(1.0, 5.0), (3.0, 1.0), (0.0, 2.0)])
:: ((0.0, 1.0), (3.0, 5.0))

turn(o, a, b)

Gives back twice the signed area of triangle (o, a, b).

turn((0.0, 0.0), (1.0, 0.0), (1.0, 1.0))
:: 1.0

convex_hull(points)

Gives back the convex hull of a set of points.

convex_hull([(0.0, 0.0), (4.0, 0.0), (4.0, 4.0), (0.0, 4.0), (2.0, 2.0)])
:: [(0.0, 0.0), (4.0, 0.0), (4.0, 4.0), (0.0, 4.0)]

point_in_polygon(p, polygon)

Tests whether a point lies inside a polygon.

point_in_polygon((2.0, 2.0), [(0.0, 0.0), (4.0, 0.0), (4.0, 4.0), (0.0, 4.0)])
:: yes

line_segments_intersect(a1, a2, b1, b2)

line_segments_intersect((0.0, 0.0), (4.0, 4.0), (0.0, 4.0), (4.0, 0.0))
:: yes

rotate_point(p, around, radians)

Rotates a point around another point by an angle in radians.

rotate_point((1.0, 0.0), (0.0, 0.0), 1.5707963267948966)
:: (6.123233995736766e-17, 1.0)

Get notified when vgeometry changes

Get notified about

New versions and security advisories.

New and updated packages, once a day.

News on the math model built in Venutian.