geometry

Primitives

Base Classes

Primitive

Base class for geometric primitives.

Classes

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.

Quaternion

Creates a Quaternion object.

Vector

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

The following representations of primitives can be used interchangeably as input in methods and functions. The representations using native Python objects also correspond to the required input parameters of the default constructor functions of the corresponding COMPAS objects.

Object

COMPAS

Python

point

Point(float, float, float)

[float, float, float]

vector

Vector(float, float, float)

[float, float, float]

line

Line(point, point)

[[float, float, float], [float, float, float]]

plane

Plane(point, vector)

[[float, float, float], [float, float, float]]

circle

Circle(plane, float)

[[[float, float, float], [float, float, float]], float]

polygon

Polygon(points)

[[float, float, float], … [float, float, float]]

polyline

Polyline(points)

[[float, float, float], … [float, float, float]]

ellipse

Ellipse(plane, float, float)

[[[float, float, float], [float, float, float]], float, float]

frame

Frame(point, vector, vector)

[[float, float, float], [float, float, float], [float, float, float]]

COMPAS primitives also support indexing, assignment, and iteration according to the above equivalency.

>>> a = Point(0, 0, 0)
>>> x, y, z = a
>>> x = a[0]
>>> a[0] = 0
>>> plane = Plane(Point(0, 0, 0), Vector(0, 0, 1))
>>> a, n = plane
>>> x, y, z = n
>>> plane[0] = Point(1, 0, 0)

Shapes

Base Classes

Shape

Base class for geometric shapes.

Classes

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.

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_polygon_convex_xy

Determine if the polygon is convex on the XY-plane.

is_point_on_line_xy

Determine if a point lies on a line on the XY-plane.

is_point_on_segment_xy

Determine if a point lies on a given line segment on the XY-plane.

is_point_on_polyline_xy

Determine if a point is on a polyline 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_in_polygon_xy

Determine if a point is in the interior of a polygon 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_circle_xy

Determine if a point lies in a circle lying 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_coplanar

Determine if the points are coplanar.

is_point_in_halfspace

is_point_in_polyhedron

Determine if the point lies inside the given polyhedron.

is_point_in_sphere

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.

is_polygon_convex

Determine if a polygon is convex.

Transformations

Classes

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

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.

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.

reflect_line_plane

Bounce a line of a reflection plane.

reflect_line_triangle

Bounce a line of a reflection triangle.

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.

scale_points

Scale points.

translate_points

Translate points.

translate_points_xy

Translate points and in the XY plane.

Conversions

axis_and_angle_from_matrix

Returns the axis and the angle of the rotation matrix M.

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.

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.

matrix_from_frame

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

matrix_from_euler_angles

Calculates a rotation matrix from Euler angles.

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_translation

Returns a 4x4 translation matrix in row-major order.

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_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_perspective_entries

Returns a matrix from perspective entries.

matrix_from_shear_entries

Returns a shear matrix from the 3 factors for x-y, x-z, and y-z axes.

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_scale_factors

Returns a 4x4 scaling transformation.

matrix_from_quaternion

Calculates a rotation matrix from quaternion coefficients.

quaternion_from_matrix

Returns the 4 quaternion coefficients from a rotation matrix.

quaternion_from_euler_angles

Returns a quaternion from Euler angles.

quaternion_from_axis_angle

Returns a quaternion describing a rotation around the given axis by the given angle.

Quaternion math

quaternion_norm

Calculates the length (euclidean norm) of a quaternion.

quaternion_unitize

Makes a quaternion unit-length.

quaternion_is_unit

Checks if a quaternion is unit-length.

quaternion_multiply

Multiplies two quaternions.

quaternion_canonize

Converts a quaternion into a canonic form if needed.

quaternion_conjugate

Conjugate of a quaternion.

Linear algebra

add_vectors

Add two vectors.

add_vectors_xy

Add two vectors, assuming they lie in the XY-plane.

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.

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.

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_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_average

Average of a vector.

vector_variance

Variance of a vector.

vector_standard_deviation

Standard deviation of a vector.

Points, Vectors, Lines, Planes

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.

distance_line_line

Compute the shortest distance between two lines.

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_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.

midpoint_point_point

Compute the midpoint of two points lying in the XY-plane.

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.

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

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_numpy

Compute the convex hull of a set of points.

convex_hull_xy

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

convex_hull_xy_numpy

Compute the convex hull of a set of points in the XY plane.

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_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.

Intersections

intersection_circle_circle_xy

Calculates the intersection points of two circles in 2d lying in the XY plane.

intersection_line_line

Computes the intersection of two lines.

intersection_line_line_xy

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

intersection_line_plane

Computes the intersection point of a line and a plane

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_plane

Computes the intersection of two planes

intersection_plane_plane_plane

Computes the intersection of three planes

intersection_ray_mesh

Compute the intersection(s) between a ray and a mesh.

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_segment_plane

Computes the intersection point of a line segment and a plane

is_intersection_line_line

Verifies if two lines intersect.

is_intersection_line_line_xy

Verifies if two lines intersect on the XY-plane.

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_intersection_segment_segment_xy

Determines if two segments, ab and cd, intersect.

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.

Fitting

bestfit_circle_numpy

Fit a circle through a set of points.

bestfit_plane

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

bestfit_plane_numpy

Fit a plane through more than three (non-coplanar) points.

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_from_points_numpy

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

delaunay_triangulation

Construct a Delaunay triangulation of set of vertices.

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_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_slice

Slice a mesh by a list of planes.

Quad meshes

quadmesh_planarize

Planarize the faces of a quad mesh.

Pointclouds

icp_numpy

Align two point clouds using the Iterative Closest Point (ICP) method.

Base Classes

Primitive

Base class for geometric primitives.

Shape

Base class for geometric shapes.