# geometry

## Classes

### Primitives

 Primitive Base class for geometric primitives. Bezier A Bezier curve. Circle A circle is defined by a plane and a radius. Ellipse A ellipse is defined by a plane and a major. Frame A frame is defined by a base point and two orthonormal base vectors. Line A line is defined by two points. Plane A plane is defined by a base point and a normal vector. Point A point is defined by XYZ coordinates. Polygon An object representing an ordered collection of points in space connected by straight line segments forming a closed boundary around the interior space. Polyline A polyline is a sequence of points connected by line segments. Pointcloud Class for working with pointclouds. Quaternion Creates a Quaternion object. Vector A vector is defined by XYZ components and a homogenisation factor.

### Shapes

 Shape Base class for geometric shapes. Box A box is defined by a frame and its dimensions along the frame’s x-, y- and z-axes. Capsule A capsule is defined by a line segment and a radius. Cone A cone is defined by a circle and a height. Cylinder A cylinder is defined by a circle and a height. Polyhedron A polyhedron is defined by its vertices and faces. Sphere A sphere is defined by a point and a radius. Torus A torus is defined by a plane and two radii.

CPython

### Transformations

 Projection Create a projection transformation. Reflection Creates a Reflection that mirrors points at a plane. Rotation Create a rotation transformation. Scale Creates a scale transformation. Shear Create a shear transformation. Transformation The Transformation represents a 4x4 transformation matrix. Translation Create a translation transformation.

## Functions

### Predicates 2D

 is_ccw_xy 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. is_colinear_xy Determine if three points are colinear on the XY-plane. is_intersection_line_line_xy Verifies if two lines intersect on the XY-plane. is_intersection_segment_segment_xy Determines if two segments, ab and cd, intersect. is_point_in_circle_xy Determine if a point lies in a circle lying on the XY-plane. is_point_in_convex_polygon_xy Determine if a point is in the interior of a convex polygon lying on the XY-plane. is_point_in_polygon_xy Determine if a point is in the interior of a polygon lying on the XY-plane. is_point_in_triangle_xy Determine if a point is in the interior of a triangle lying on the XY-plane. is_point_on_line_xy Determine if a point lies on a line on the XY-plane. is_point_on_polyline_xy Determine if a point is on a polyline on the XY-plane. is_point_on_segment_xy Determine if a point lies on a given line segment on the XY-plane. is_polygon_convex_xy Determine if the polygon is convex on the XY-plane. is_polygon_in_polygon_xy Determine if a polygon is in the interior of another polygon on the XY-plane.

### Predicates 3D

 is_colinear Determine if three points are colinear. is_colinear_line_line Determine if two lines are colinear. is_coplanar Determine if the points are coplanar. is_intersection_line_line Verifies if two lines intersect. is_intersection_line_plane Determine if a line (ray) intersects with a plane. is_intersection_line_triangle Verifies if a line (ray) intersects with a triangle. is_intersection_plane_plane Verifies if two planes intersect. is_intersection_segment_plane Determine if a line segment intersects with a plane. is_intersection_segment_segment Verifies if two segments intersect. is_polygon_convex Determine if a polygon is convex. is_point_behind_plane Determine if a point lies behind a plane. is_point_infront_plane Determine if a point lies in front of a plane. is_point_in_circle Determine if a point lies in a circle. is_point_in_halfspace Determine if a point lies in front of a plane. is_point_in_polyhedron Determine if the point lies inside the given polyhedron. is_point_in_triangle Determine if a point is in the interior of a triangle. is_point_on_line Determine if a point lies on a line. is_point_on_plane Determine if a point lies on a plane. is_point_on_polyline Determine if a point is on a polyline. is_point_on_segment Determine if a point lies on a given line segment.

### Transformations

 mirror_point_plane Mirror a point about a plane. mirror_points_line Mirror a point about a line. mirror_points_line_xy Mirror a point about a line. mirror_points_plane Mirror a point about a plane. mirror_points_point Mirror multiple points about a point. mirror_points_point_xy Mirror multiple points about a point. mirror_vector_vector Mirrors vector about vector. orient_points Orient points from one plane to another. project_point_line Project a point onto a line. project_point_line_xy Project a point onto a line in the XY plane. project_point_plane Project a point onto a plane. project_points_line Project points onto a line. project_points_line_xy Project points onto a line in the XY plane. project_points_plane Project multiple points onto a plane. rotate_points Rotates points around an arbitrary axis in 3D. rotate_points_xy Rotates points in the XY plane around the Z axis at a specific origin. reflect_line_plane Bounce a line of a reflection plane. reflect_line_triangle Bounce a line of a reflection triangle. scale_points Scale points. scale_points_xy Scale points in the XY plane. translate_points Translate points. translate_points_xy Translate points and in the XY plane.
 axis_angle_vector_from_matrix Returns the axis-angle vector of the rotation matrix M. axis_angle_from_quaternion Returns an axis and an angle of rotation from the given quaternion. basis_vectors_from_matrix Returns the basis vectors from the rotation matrix R. compose_matrix Calculates a matrix from the components of scale, shear, euler_angles, translation and perspective. decompose_matrix Calculates the components of rotation, translation, scale, shear, and perspective of a given transformation matrix M. euler_angles_from_matrix Returns Euler angles from the rotation matrix M according to specified axis sequence and type of rotation. euler_angles_from_quaternion Returns Euler angles from a quaternion. axis_and_angle_from_matrix Returns the axis and the angle of the rotation matrix M. identity_matrix Construct an identity matrix. local_axes local_to_world_coordinates Convert local coordinates to global coordinates. matrix_determinant Calculates the determinant of a square matrix M. matrix_from_axis_and_angle Calculates a rotation matrix from an rotation axis, an angle and an optional point of rotation. matrix_from_axis_angle_vector Calculates a rotation matrix from an axis-angle vector. matrix_from_basis_vectors Creates a rotation matrix from basis vectors (= orthonormal vectors). matrix_from_change_of_basis Computes a change of basis transformation between two frames. matrix_from_euler_angles Calculates a rotation matrix from Euler angles. matrix_from_frame Computes a change of basis transformation from world XY to the frame. matrix_from_frame_to_frame Computes a transformation between two frames. matrix_from_orthogonal_projection Returns an orthogonal projection matrix to project onto a plane. matrix_from_parallel_projection Returns an parallel projection matrix to project onto a plane. matrix_from_perspective_entries Returns a matrix from perspective entries. matrix_from_perspective_projection Returns a perspective projection matrix to project onto a plane along lines that emanate from a single point, called the center of projection. matrix_from_quaternion Calculates a rotation matrix from quaternion coefficients. matrix_from_scale_factors Returns a 4x4 scaling transformation. matrix_from_shear Constructs a shear matrix by an angle along the direction vector on the shear plane (defined by point and normal). matrix_from_shear_entries Returns a shear matrix from the 3 factors for x-y, x-z, and y-z axes. matrix_from_translation Returns a 4x4 translation matrix in row-major order. matrix_inverse Calculates the inverse of a square matrix M. orthonormalize_axes Corrects xaxis and yaxis to be unit vectors and orthonormal. quaternion_canonize Converts a quaternion into a canonic form if needed. quaternion_conjugate Conjugate of a quaternion. quaternion_from_axis_angle Returns a quaternion describing a rotation around the given axis by the given angle. quaternion_from_euler_angles Returns a quaternion from Euler angles. quaternion_from_matrix Returns the 4 quaternion coefficients from a rotation matrix. quaternion_is_unit Checks if a quaternion is unit-length. quaternion_multiply Multiplies two quaternions. quaternion_norm Calculates the length (euclidean norm) of a quaternion. quaternion_unitize Makes a quaternion unit-length. transform_frames Transform multiple frames with one transformation matrix. transform_points Transform multiple points with one transformation matrix. transform_vectors Transform multiple vectors with one transformation matrix. translation_from_matrix Returns the 3 values of translation from the matrix M. world_to_local_coordinates Convert global coordinates to local coordinates.

CPython

 dehomogenize_numpy Dehomogenizes points or vectors. dehomogenize_and_unflatten_frames_numpy Dehomogenize a list of vectors and unflatten the 2D list into a 3D list. homogenize_numpy Dehomogenizes points or vectors. homogenize_and_flatten_frames_numpy Homogenize a list of frames and flatten the 3D list into a 2D list using numpy. local_to_world_coordinates_numpy Convert local coordinates to global (world) coordinates. transform_points_numpy Transform multiple points with one Transformation using numpy. transform_vectors_numpy Transform multiple vectors with one Transformation using numpy. world_to_local_coordinates_numpy Convert global coordinates to local coordinates.

### Linear algebra

 add_vectors Add two vectors. add_vectors_xy Add two vectors, assuming they lie in the XY-plane. allclose Returns True if two lists are element-wise equal within a tolerance. argmax Returns the index of the first maximum value within an array. argmin Returns the index of the first minimum value within an array. close Returns True if two values are equal within a tolerance. cross_vectors Compute the cross product of two vectors. cross_vectors_xy Compute the cross product of two vectors, assuming they lie in the XY-plane. dehomogenize_vectors Dehomogenise a list of vectors. divide_vectors Element-wise division of two vectors. divide_vectors_xy Element-wise division of two vectors assumed to lie in the XY plane. dot_vectors Compute the dot product of two vectors. dot_vectors_xy Compute the dot product of two vectors, assuming they lie in the XY-plane. homogenize_vectors Homogenise a list of vectors. length_vector Calculate the length of the vector. length_vector_xy Compute the length of a vector, assuming it lies in the XY plane. length_vector_sqrd Compute the squared length of a vector. length_vector_sqrd_xy Compute the squared length of a vector, assuming it lies in the XY plane. multiply_matrices Mutliply a matrix with a matrix. multiply_matrix_vector Multiply a matrix with a vector. multiply_vectors Element-wise multiplication of two vectors. multiply_vectors_xy Element-wise multiplication of two vectors assumed to lie in the XY plane. norm_vector Calculate the length of a vector. norm_vectors Calculate the norm of each vector in a list of vectors. normalize_vector Normalise a given vector. normalize_vector_xy Normalize a vector, assuming it lies in the XY-plane. normalize_vectors Normalise multiple vectors. normalize_vectors_xy Normalise multiple vectors, assuming they lie in the XY plane. orthonormalize_vectors Orthonormalize a set of vectors. power_vector Raise a vector to the given power. power_vectors Raise a list of vectors to the given power. scale_vector Scale a vector by a given factor. scale_vector_xy Scale a vector by a given factor, assuming it lies in the XY plane. scale_vectors Scale multiple vectors by a given factor. scale_vectors_xy Scale multiple vectors by a given factor, assuming they lie in the XY plane. square_vector Raise a vector to the power 2. square_vectors Raise a multiple vectors to the power 2. subtract_vectors Subtract one vector from another. subtract_vectors_xy Subtract one vector from another, assuming they lie in the XY plane. sum_vectors Calculate the sum of a series of vectors along the specified axis. transpose_matrix Transpose a matrix. vector_average Average of a vector. vector_component Compute the component of u in the direction of v. vector_component_xy Compute the component of u in the direction of v, assuming they lie in the XY-plane. vector_standard_deviation Standard deviation of a vector. vector_variance Variance of a vector.

### Analytical

 archimedean_spiral_evaluate Evalutes a spiral at a parameter. circle_evaluate Evalutes a circle at a parameter. helix_evaluate Evalutes an helix at a parameter. logarithmic_spiral_evaluate Evalutes a logarithmic spiral at a parameter.

### Points, Vectors, Lines, Planes, Circles

 angle_points Compute the smallest angle between the vectors defined by three points. angle_points_xy Compute the smallest angle between the vectors defined by the XY components of three points. angle_vectors Compute the smallest angle between two vectors. angle_vectors_xy Compute the smallest angle between the XY components of two vectors. angle_vectors_signed Computes the signed angle between two vectors. angles_points Compute the two angles between two vectors defined by three points. angles_points_xy Compute the two angles between the two vectors defined by the XY components of three points. angles_vectors Compute the the 2 angles formed by a pair of vectors. angles_vectors_xy Compute the angles between the XY components of two vectors. angle_planes Compute the smallest angle between the two normal vectors of two planes. centroid_points Compute the centroid of a set of points. centroid_points_xy Compute the centroid of a set of points lying in the XY-plane. centroid_points_weighted Compute the weighted centroid of a set of points. circle_from_points Construct a circle from three points. circle_from_points_xy Create a circle from three points lying in the XY-plane midpoint_point_point Compute the midpoint of two points. midpoint_point_point_xy Compute the midpoint of two points lying in the XY-plane. midpoint_line Compute the midpoint of a line defined by two points. midpoint_line_xy Compute the midpoint of a line defined by two points. tangent_points_to_circle_xy Calculates the tangent points on a circle in the XY plane.

### Polygons & Polyhedrons

 area_polygon Compute the area of a polygon. area_polygon_xy Compute the area of a polygon lying in the XY-plane. area_triangle Compute the area of a triangle defined by three points. area_triangle_xy Compute the area of a triangle defined by three points lying in the XY-plane. centroid_polygon Compute the centroid of the surface of a polygon. centroid_polygon_xy Compute the centroid of the surface of a polygon projected to the XY plane. centroid_polygon_vertices Compute the centroid of the vertices of a polygon. centroid_polygon_vertices_xy centroid_polygon_edges Compute the centroid of the edges of a polygon. centroid_polygon_edges_xy centroid_polyhedron Compute the center of mass of a polyhedron. normal_polygon Compute the normal of a polygon defined by a sequence of points. normal_triangle Compute the normal vector of a triangle. normal_triangle_xy Compute the normal vector of a triangle assumed to lie in the XY plane. volume_polyhedron Compute the volume of a polyhedron represented by a closed mesh.

### Point Sets

 KDTree A tree for nearest neighbor search in a k-dimensional space.
 bestfit_plane Fit a plane to a list of (more than three) points. bounding_box Computes the axis-aligned minimum bounding box of a list of points. bounding_box_xy Compute the axis-aligned minimum bounding box of a list of points in the XY-plane. convex_hull Construct convex hull for a set of points. convex_hull_xy Computes the convex hull of a set of 2D points.

CPython

 bestfit_circle_numpy Fit a circle through a set of points. bestfit_frame_numpy Fit a frame to a set of points. bestfit_plane_numpy Fit a plane through more than three (non-coplanar) points. bestfit_sphere_numpy Returns the sphere’s center and radius that fits best through a set of points. convex_hull_numpy Compute the convex hull of a set of points. convex_hull_xy_numpy Compute the convex hull of a set of points in the XY plane. icp_numpy Align two point clouds using the Iterative Closest Point (ICP) method. oabb_numpy oriented_bounding_box_numpy Compute the oriented minimum bounding box of a set of points in 3D space. oriented_bounding_box_xy_numpy Compute the oriented minimum bounding box of set of points in the XY plane.

### Distance

 closest_line_to_point Compute closest line to a point from a list of lines. closest_point_in_cloud Calculates the closest point in a pointcloud. closest_point_in_cloud_xy Calculates the closest point in a list of points in the XY-plane. closest_point_on_line Computes closest point on line to a given point. closest_point_on_line_xy Compute closest point on line (continuous) to a given point lying in the XY-plane. closest_point_on_plane Compute closest point on a plane to a given point. closest_point_on_polyline Find the closest point on a polyline to a given point. closest_point_on_polyline_xy Compute closest point on a polyline to a given point, assuming they both lie in the XY-plane. closest_point_on_segment Computes closest point on line segment (p1, p2) to test point. closest_point_on_segment_xy Compute closest point on a line segment to a given point lying in the XY-plane. distance_line_line Compute the shortest distance between two lines. distance_point_point Compute the distance bewteen a and b. distance_point_point_xy Compute the distance between points a and b, assuming they lie in the XY plane. distance_point_point_sqrd Compute the squared distance bewteen points a and b. distance_point_point_sqrd_xy Compute the squared distance between points a and b lying in the XY plane. distance_point_line Compute the distance between a point and a line. distance_point_line_xy Compute the distance between a point and a line, assuming they lie in the XY-plane. distance_point_line_sqrd Compute the squared distance between a point and a line. distance_point_line_sqrd_xy Compute the squared distance between a point and a line lying in the XY-plane. distance_point_plane Compute the distance from a point to a plane defined by origin point and normal. distance_point_plane_signed Compute the signed distance from a point to a plane defined by origin point and normal.

### Intersections

 intersection_circle_circle_xy Calculates the intersection points of two circles in 2d lying in the XY plane. intersection_ellipse_line_xy Computes the intersection of an ellipse and a line in the XY plane. intersection_line_box_xy Compute the intersection between a line and a box in the XY plane. intersection_line_line_xy Compute the intersection of two lines, assuming they lie on the XY plane. intersection_line_line Computes the intersection of two lines. intersection_line_plane Computes the intersection point of a line and a plane intersection_line_segment_xy intersection_line_segment Compute the intersection of a line and a segment. intersection_line_triangle Computes the intersection point of a line (ray) and a triangle based on the Moeller Trumbore intersection algorithm intersection_mesh_mesh Compute the intersection of tow meshes. intersection_plane_circle Computes the intersection of a plane and a circle. intersection_plane_plane_plane Computes the intersection of three planes intersection_plane_plane Computes the intersection of two planes intersection_polyline_plane Calculate the intersection point of a plane with a polyline. intersection_ray_mesh Compute the intersection(s) between a ray and a mesh. intersection_segment_plane Computes the intersection point of a line segment and a plane intersection_segment_polyline Calculate the intersection point of a segment and a polyline. intersection_segment_polyline_xy Calculate the intersection point of a segment and a polyline on the XY-plane. intersection_segment_segment Compute the intersection of two lines segments. intersection_segment_segment_xy Compute the intersection of two lines segments, assuming they lie in the XY plane. intersection_sphere_line Computes the intersection of a sphere and a line. intersection_sphere_sphere Computes the intersection of 2 spheres.

### Offsets

 offset_line Offset a line by a distance. offset_polyline Offset a polyline by a distance. offset_polygon Offset a polygon (closed) by a distance.

### Interpolation

 barycentric_coordinates Compute the barycentric coordinates of a point wrt to a triangle. discrete_coons_patch Creates a coons patch from a set of four or three boundary polylines (ab, bc, dc, ad). tween_points Compute the interpolated points between two sets of points. tween_points_distance Compute an interpolated set of points between two sets of points, at a given distance.

### Offsets

 offset_line Offset a line by a distance. offset_polyline Offset a polyline by a distance. offset_polygon Offset a polygon (closed) by a distance.

### Boolean operations

 boolean_union_mesh_mesh Compute the boolean union of two triangle meshes. boolean_difference_mesh_mesh Compute the boolean difference of two triangle meshes. boolean_intersection_mesh_mesh Compute the boolean intersection of two triangle meshes.

### Triangulation

 conforming_delaunay_triangulation Construct a Conforming Delaunay triangulation of set of vertices, constrained to the specified segments. constrained_delaunay_triangulation Construct a Delaunay triangulation of set of vertices, constrained to the specified segments. delaunay_from_points Computes the delaunay triangulation for a list of points. delaunay_triangulation Construct a Delaunay triangulation of set of vertices.

CPython

 delaunay_from_points_numpy Computes the delaunay triangulation for a list of points using Numpy. voronoi_from_points_numpy Generate a voronoi diagram from a set of points.

### Triangle meshes

 trimesh_gaussian_curvature Compute the discrete gaussian curvature of a triangle mesh. trimesh_geodistance Compute the geodesic distance from every vertex of the mesh to a source vertex. trimesh_harmonic Compute the harmonic parametrisation of a triangle mesh within a fixed circular boundary. trimesh_isolines Compute isolines on a triangle mesh using a scalarfield of data points assigned to its vertices. trimesh_lscm Compute the least squares conformal map of a triangle mesh. trimesh_mean_curvature Compute the discrete mean curvature of a triangle mesh. trimesh_massmatrix Compute massmatrix on a triangle mesh using a scalarfield of data points assigned to its vertices. trimesh_principal_curvature Compute the principal curvature directions of a triangle mesh. trimesh_remesh Remeshing of a triangle mesh. trimesh_remesh_constrained Constrained remeshing of a triangle mesh. trimesh_remesh_along_isoline Remesh a mesh along an isoline of a scalarfield over the vertices. trimesh_slice Slice a mesh by a list of planes.

 quadmesh_planarize Planarize the faces of a quad mesh.