geometry
The functions of this package take various geometric primitives as input parameters. These primitives may be passed into those functions as instances of the corresponding classes or as an equivalent representation using (combinations of) builtin Python objects. The following table defines those equivalent representations.
parameter 
representation 

vector 
list of XYZ coordinates. 
point 
list of XYZ coordinates. 
segment 
2tuple of points. 
line 
2tuple of points. 
ray 
2tuple of points. 
polyline 
list of points. 
polygon 
list of points. 
plane 
2tuple of origin (point) and normal (vector). 
frame 
3tuple of origin (point), U axis (vector) and V axis (vector). 
circle 
3tuple of center (point), normal (vector) and radius (float). 
>>> cross_vectors([1.0, 0.0, 0.0], [0.0, 1.0, 0.0])
[0.0, 0.0, 1.0]
>>> cross_vectors(Vector(1, 0, 0), [0, 1, 0])
[0.0, 0.0, 1.0]
>>> cross_vectors(Vector(1, 0, 0), Vector(0, 1, 0))
[0.0, 0.0, 1.0]
>>> points = [[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [1.0, 1.0, 0.0], [0.0, 1.0, 0.0]]
>>> area_polygon(points) == area_polygon(Polygon(points))
True
Many functions also have an _xy
variant.
These variants ignore the Zcomponent of the input parameters.
Therefore, they also accept 2D representations of geometric objects.
However, they always return a 3D result in the XY plane (with z = 0
).
For example, scale_vector_xy
accepts both 2D and 3D vectors,
but always returns a 3D vector with the Zcomponent set to zero.
>>> points = [[0.0, 0.0, 1.0], [1.0, 0.0, 0.0], [1.0, 1.0, 1.0], [0.0, 1.0, 0.0]]
>>> area_polygon_xy(points) == area_polygon(points)
False
Primitives
A box is defined by a frame and its dimensions along the frame’s x, y and zaxes. 

A circle is defined by a plane and a radius. 

A cone is defined by a circle and a height. 

A cylinder is defined by a circle and a height. 

A frame is defined by a base point and two orthonormal base vectors. 

A line is defined by two points. 

A plane is defined by a base point and a normal vector. 

A point is defined by XYZ coordinates. 

An object representing an ordered collection of points in space connected by straight line segments forming a closed boundary around the interior space. 

Compute the vertices and faces of one of the Platonic solids. 

A polyline is a sequence of points connected by line segments. 

Creates a 

A sphere is defined by a point and a radius. 

A torus is defined by a plane and two radii. 

A vector is defined by XYZ components and a homogenisation factor. 
Transformations
XForms
Creates a 



Creates a scaling transformation. 

Constructs a 

The 

Creates a translation transformation. 
Functions
Mirror a point about a line. 

Mirror a point about a line. 

Mirror a point about a plane. 

Mirror multiple points about a point. 

Mirror multiple points about a point. 

Project points onto a line. 

Project points onto a line in the XY plane. 

Project multiple points onto a plane. 

Bounce a line of a reflection plane. 

Bounce a line of a reflection triangle. 

Rotates points around an arbitrary axis in 3D. 

Rotates points in the XY plane around the Z axis at a specific origin. 

Scale points. 

Translate points. 

Translate points and in the XY plane. 
Conversions
Returns the axis and the angle of the rotation matrix M. 

Returns the axisangle vector of the rotation matrix M. 

Returns an axis and an angle of rotation from the given quaternion. 

Returns the basis vectors from the rotation matrix R. 

Returns Euler angles from the rotation matrix M according to specified axis sequence and type of rotation. 

Returns Euler angles from a quaternion. 

Computes a change of basis transformation from world XY to the frame. 

Calculates a rotation matrix from Euler angles. 

Calculates a rotation matrix from an rotation axis, an angle and an optional point of rotation. 

Calculates a rotation matrix from an axisangle vector. 

Creates a rotation matrix from basis vectors (= orthonormal vectors). 

Returns a 4x4 translation matrix in rowmajor order. 

Returns an orthogonal projection matrix to project onto a plane defined by point and normal. 

Returns an parallel projection matrix to project onto a plane defined by point, normal and direction. 

Returns a perspective projection matrix to project onto a plane defined by point, normal and perspective. 

Returns a matrix from perspective entries. 

Returns a shear matrix from the 3 factors for xy, xz, and yz axes. 

Constructs a shear matrix by an angle along the direction vector on the shear plane (defined by point and normal). 

Returns a 4x4 scaling transformation. 

Calculates a rotation matrix from quaternion coefficients. 

Returns the 4 quaternion coefficients from a rotation matrix. 

Returns a quaternion from Euler angles. 

Returns a quaternion describing a rotation around the given axis by the given angle. 
Quaternion math
Calculates the length (euclidean norm) of a quaternion. 

Makes a quaternion unitlength. 

Checks if a quaternion is unitlength. 

Multiplies two quaternions. 

Converts a quaternion into a canonic form if needed. 

Conjugate of a quaternion. 
Linear algebra
Add two vectors. 

Add two vectors, assuming they lie in the XYplane. 

Compute the cross product of two vectors. 

Compute the cross product of two vectors, assuming they lie in the XYplane. 

Elementwise division of two vectors. 

Elementwise division of two vectors assumed to lie in the XY plane. 

Compute the dot product of two vectors. 

Compute the dot product of two vectors, assuming they lie in the XYplane. 

Calculate the length of the vector. 

Compute the length of a vector, assuming it lies in the XY plane. 

Compute the squared length of a vector. 

Compute the squared length of a vector, assuming it lies in the XY plane. 

Mutliply a matrix with a matrix. 

Multiply a matrix with a vector. 

Elementwise multiplication of two vectors. 

Elementwise multiplication of two vectors assumed to lie in the XY plane. 

Calculate the length of a vector. 

Calculate the norm of each vector in a list of vectors. 

Normalise a given vector. 

Normalize a vector, assuming it lies in the XYplane. 

Normalise multiple vectors. 

Normalise multiple vectors, assuming they lie in the XY plane. 

Orthonormalize a set of vectors. 

Raise a vector to the given power. 

Raise a list of vectors to the given power. 

Scale a vector by a given factor. 

Scale a vector by a given factor, assuming it lies in the XY plane. 

Scale multiple vectors by a given factor. 

Scale multiple vectors by a given factor, assuming they lie in the XY plane. 

Raise a vector to the power 2. 

Raise a multiple vectors to the power 2. 

Subtract one vector from another. 

Subtract one vector from another, assuming they lie in the XY plane. 

Calculate the sum of a series of vectors along the specified axis. 

Transpose a matrix. 

Compute the component of u in the direction of v. 

Compute the component of u in the direction of v, assuming they lie in the XYplane. 
Points, Vectors, Lines, Planes
Angles
Compute the smallest angle between the vectors defined by three points. 

Compute the smallest angle between the vectors defined by the XY components of three points. 

Compute the smallest angle between two vectors. 

Compute the smallest angle between the XY components of two vectors. 

Compute the two angles between two vectors defined by three points. 

Compute the two angles between the two vectors defined by the XY components of three points. 

Compute the the 2 angles formed by a pair of vectors. 

Compute the angles between the XY components of two vectors. 
Distance
Compute the shortest distance between two lines. 

Compute the distance between a point and a line. 

Compute the distance between a point and a line, assuming they lie in the XYplane. 

Compute the squared distance between a point and a line. 

Compute the squared distance between a point and a line lying in the XYplane. 

Compute the distance from a point to a plane defined by origin point and normal. 

Compute the distance bewteen a and b. 

Compute the distance between points a and b, assuming they lie in the XY plane. 

Compute the squared distance bewteen points a and b. 

Compute the squared distance between points a and b lying in the XY plane. 
Centroids
Compute the centroid of a set of points. 

Compute the centroid of a set of points lying in the XYplane. 

Compute the midpoint of two points lying in the XYplane. 

Compute the midpoint of two points lying in the XYplane. 

Compute the midpoint of a line defined by two points. 

Compute the midpoint of a line defined by two points. 

Compute the weighted centroid of a set of points. 
Polygons & Polyhedrons
Centroid
Compute the centroid of the surface of a polygon. 

Compute the centroid of the surface of a polygon projected to the XY plane. 

Compute the centroid of the vertices of a polygon. 

Compute the centroid of the edges of a polygon. 

Compute the center of mass of a polyhedron. 
Area and volume
Compute the area of a polygon. 

Compute the area of a polygon lying in the XYplane. 

Compute the area of a triangle defined by three points. 

Compute the area of a triangle defined by three points lying in the XYplane. 

Compute the volume of a polyhedron represented by a closed mesh. 
Normals
Compute the normal of a polygon defined by a sequence of points. 

Compute the normal vector of a triangle. 

Compute the normal vector of a triangle assumed to lie in the XY plane. 
Pointclouds
Bounding Box
Computes the axisaligned minimum bounding box of a list of points. 

Compute the axisaligned minimum bounding box of a list of points in the XYplane. 

Compute the oriented minimum bounding box of a set of points in 3D space. 

Compute the oriented minimum bounding box of set of points in the XY plane. 
Convex Hull
Construct convex hull for a set of points. 

Compute the convex hull of a set of points. 

Computes the convex hull of a set of 2D points. 

Compute the convex hull of a set of points in the XY plane. 
Triangulation
Computes the delaunay triangulation for a list of points. 

Computes the delaunay triangulation for a list of points using Numpy. 

Generate a voronoi diagram from a set of points. 
Queries
Determine if c is on the left of ab when looking from a to b, and assuming that all points lie in the XY plane. 

Determine if three points are colinear. 

Determine if three points are colinear in the XY plane. 

Determine if the points are coplanar. 

Verifies if two lines intersection in one point. 

Determine if two lines intersect in 2d lying in the XY plane. 

Determine if a line (continuous ray) intersects with a plane. 

Verifies if a line (ray) intersects with a triangle. 

Computes the intersection of two planes 

Determine if a line segment intersects with a plane. 

Determine if two the segments ab and cd intersect? 

Determine if a polygon is convex. 

Determine if the polygon is convex in the XYplane. 

Determine if a point lies in a circle. 

Determine if a point lies in a circle lying in the XY plane. 

Determine if a point is in the interior of a convex polygon lying in the XYplane. 

Determine if a point lies on a line. 

Determine if a point lies on a line in the XYplane. 

Determine if a point lies in a plane. 

Determine if a point lies in front of a plane. 

Determine if a point is in the interior of a polygon lying in the XYplane. 

Determine if a point is on a polyline. 

Determine if a point lies on a given line segment. 

Determine if a point lies on a given line segment in the XYplane. 

Determine if a point is in the interior of a triangle. 

Determine if a point is in the interior of a triangle lying in the XYplane. 
Proximity
Calculates the closest point in a pointcloud. 

Calculates the closest point in a list of points in the XYplane. 

Computes closest point on line to a given point. 

Compute closest point on line (continuous) to a given point lying in the XYplane. 

Compute closest point on a plane to a given point. 

Find the closest point on a polyline to a given point. 

Compute closest point on a polyline to a given point, assuming they both lie in the XYplane. 

Computes closest point on line segment (p1, p2) to testpoint. 

Compute closest point on line segment to a given point lying in the XYplane. 
Intersections
Calculates the intersection points of two circles in 2d lying in the XY plane. 

Computes the intersection of two lines. 

Compute the intersection of two lines, assuming they lie in the XY plane. 

Computes the intersection point of a line and a plane 

Computes the intersection point of a line (ray) and a triangle based on the Moeller Trumbore intersection algorithm 

Computes the intersection of two planes 

Computes the intersection of three planes 

Compute the intersection of two lines segments, assuming they lie in the XY plane. 

Computes the intersection point of a line segment and a plane 
Offsets
Offset a line by a distance. 

Offset a polyline by a distance. 

Offset a polygon (closed) by a distance. 
Optimisation
Smoothing
Smooth a connected set of vertices by moving each vertex to the centroid of its neighbors. 

Smooth a connected set of vertices by moving each vertex to the center of mass of the polygon formed by the neighboring vertices. 

Smooth a set of connected vertices by moving each vertex to the centroid of the surrounding faces, weighted by the area of the face. 
Planarisation
Compute mesh flatness per face. 

Planarise a set of connected faces. 
Interpolation
Creates a coons patch from a set of four or three boundary polylines (ab, bc, dc, ad). 

Compute the interpolated points between two sets of points. 

Compute an interpolated set of points between two sets of points, at a given distance. 
Bestfit
Fit a circle through a set of points. 

Fit a plane to a list of (more than three) points. 

Fit a plane through more than three (noncoplanar) points. 
Other functions
Parametric curves
Evalutes a spiral at a parameter. 

Evalutes a circle at a parameter. 

Evalutes an ellipse at a parameter. 

Evalutes an helix at a parameter. 

Evalutes a logarithmic spiral at a parameter. 
Isolines
Compute the contour lines of a scalarfield. 