compas.geometry

This package defines all functionality for working with geometry in COMPAS. It provides classes representing geometric primitives, transformations, (NURBS) curves and surfaces, shapes, general polygons and polyhedrons, boundary representations (B-reps), and a number of geometry processing algorithms.

Classes

Arc

An arc is a segment of a circle, and is defined by a coordinate system, radius, and start and end angles.

Bezier

A Bezier curve is defined by control points and a degree.

Box

A box is defined by a frame and its dimensions along the frame's x-, y- and z-axes.

Brep

Contains the topological and geometrical information of a Brep shape.

BrepEdge

An interface for a Brep Edge

BrepError

Represents a generic error in the Brep context

BrepFace

An interface for a Brep Face.

BrepFilletError

Raised when a fillet operation has failed or had not result

BrepInvalidError

Raised when the process of re-constructing a Brep has resulted in an invalid Brep

BrepLoop

An interface for a Brep Loop.

BrepOrientation

Possible orientations of a Brep

BrepTrim

An interface for a Brep Trim

BrepTrimIsoStatus

An enumeration of isoparametric curve direction on the surface.

BrepTrimmingError

Raised when a trimming operation has failed or had not result

BrepType

Possible types of a Brep

BrepVertex

An interface for a Brep Vertex

Capsule

A capsule is defined by a frame, radius, and height.

Circle

A circle is a curve defined by a coordinate system and a radius.

Cone

A cone is defined by a frame, radius, and height.

ConicalSurface

A cylindrical surface is defined by a radius and a local coordinate system.

Curve

Class representing a general parametric curve.

CurveType

Enumaration of curve types.

Cylinder

A cylinder is defined by a frame, radius, and height.

CylindricalSurface

A cylindrical surface is defined by a radius and a local coordinate system.

Ellipse

An ellipse is a curve defined by a coordinate system and a major and minor axis.

Frame

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

Geometry

Base class for all geometric objects.

Hyperbola

A hyperbola is defined by a coordinate frame and a major and minor axis.

KDTree

A tree for nearest neighbor search in a k-dimensional space.

Line

A line is a curve defined by two points.

NurbsCurve

A NURBS curve is defined by control points, weights, knots, and a degree.

NurbsSurface

A NURBS surface is defined by control points, weights, knots, and a degree, in two directions U and V.

Parabola

A parabola is defined by a plane and a major and minor axis.

PlanarSurface

A planar surface is defined by a local coordinate system and a size.

Plane

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

Point

A point is defined by XYZ coordinates.

Pointcloud

Class for working with pointclouds.

Polygon

A polygon is a geometric object defined by a sequence of points forming a closed loop.

Polyhedron

A polyhedron is a geometric object defined by its vertices and faces.

Polyline

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

Projection

Class representing a projection transformation.

Quaternion

A quaternion is defined by 4 components, X, Y, Z, and W.

Reflection

Class representing a reflection transformation.

Rotation

Class representing a rotation transformation.

Scale

Class representing a scale transformation.

Shape

Base class for geometric shapes.

Shear

Class representing a shear transformation.

Sphere

A sphere is defined by a point and a radius.

SphericalSurface

A spherical surface is defined by a radius and a frame.

Surface

Class representing a general surface object.

SurfaceType

Enumaration of surface types.

ToroidalSurface

A spherical surface is defined by a radius and a frame.

Torus

A torus is defined by a plane and two radii.

Transformation

Class representing a general 4x4 transformation matrix.

Translation

Class representing a translation transformation.

Vector

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

Functions

add_vectors

Add two vectors.

add_vectors_xy

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

angle_planes

Compute the smallest angle between the two normal vectors of two 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_signed

Computes the signed angle between two vectors.

angle_vectors_xy

Compute the smallest angle between the XY components of 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.

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.

argmax

Returns the index of the first maximum value within an array.

argmin

Returns the index of the first minimum value within an array.

axis_and_angle_from_matrix

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

axis_angle_from_quaternion

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

axis_angle_vector_from_matrix

Returns the axis-angle vector of the rotation matrix M.

barycentric_coordinates

Compute the barycentric coordinates of a point wrt to a triangle.

basis_vectors_from_matrix

Returns the basis vectors from the rotation matrix R.

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.

centroid_points

Compute the centroid of a set of points.

centroid_points_weighted

Compute the weighted centroid of a set of points.

centroid_points_xy

Compute the centroid of a set of points lying in the XY-plane.

centroid_polygon

Compute the centroid of the surface of a polygon.

centroid_polygon_edges

Compute the centroid of the edges of a polygon.

centroid_polygon_edges_xy

Compute the centroid of the edges of a polygon prohected to the XY plane.

centroid_polygon_vertices

Compute the centroid of the vertices of a polygon.

centroid_polygon_vertices_xy

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

centroid_polygon_xy

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

centroid_polyhedron

Compute the center of mass of a polyhedron.

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_polygon_xy

Compute closest point on a polygon to a given point lying in the XY-plane.

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.

compose_matrix

Calculates a matrix from the components of scale, shear, euler_angles, translation and perspective.

compute_basisfuncs

Compute the nonzero basis functions for a given parameter value.

compute_basisfuncsderivs

Compute the derivatives of the basis functions for a given parameter value.

construct_knotvector

Construct a nonperiodic (clamped), uniform knot vector for a curve with given degree and number of control points.

convex_hull

Construct convex hull for a set of points.

convex_hull_xy

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

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.

decompose_matrix

Calculates the components of rotation, translation, scale, shear, and perspective of a given transformation matrix M.

dehomogenize_vectors

Dehomogenise a list of vectors.

discrete_coons_patch

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

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

Compute the distance between a point and a line, assuming they lie 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.

distance_point_point

Compute the distance bewteen a and b.

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_point_xy

Compute the distance between points a and b, 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.

earclip_polygon

Triangulate a polygon using the ear clipping method.

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.

find_span

Find the knot span index for a given knot value.

homogenize_vectors

Homogenise a list of vectors.

identity_matrix

Construct an identity matrix.

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

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_segment

Compute the intersection of a line and a segment.

intersection_line_segment_xy

Compute the intersection between 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_plane_circle

Computes the intersection of a plane and a circle.

intersection_plane_plane

Computes the intersection of two planes

intersection_plane_plane_plane

Computes the intersection of three planes

intersection_polyline_box_xy

Compute the intersection between a polyline and a box in the XY plane.

intersection_polyline_plane

Calculate the intersection point of a plane with a polyline.

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.

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

Determine if three points are colinear.

is_colinear_line_line

Determine if two lines are colinear.

is_colinear_xy

Determine if three points are colinear on the XY-plane.

is_coplanar

Determine if the points are coplanar.

is_matrix_square

Verify that a matrix is square.

is_parallel_line_line

Determine if two lines are parallel.

is_parallel_vector_vector

Determine if two vectors are parallel.

is_point_behind_plane

Determine if a point lies behind a plane.

is_point_in_circle

Determine if a point lies in a circle.

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

Determine if a point is in the interior of a triangle lying on the XY-plane.

is_point_infrontof_plane

Determine if a point lies in front of a plane.

is_point_on_line

Determine if a point lies on a line.

is_point_on_line_xy

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

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_polyline_xy

Determine if a point is on a polyline on the XY-plane.

is_point_on_segment

Determine if a point lies on a given line segment.

is_point_on_segment_xy

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

is_polygon_convex

Determine if a polygon is convex.

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.

knots_and_mults_to_knotvector

Convert a list of knots and multiplicities to a knot vector.

knotvector_to_knots_and_mults

Convert a knot vector to a list of knots and multiplicities.

length_vector

Calculate the length of the vector.

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.

length_vector_xy

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

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.

matrix_minor

Construct the minor corresponding to an element of a matrix.

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.

midpoint_point_point

Compute the midpoint of two points.

midpoint_point_point_xy

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

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.

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.

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.

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.

offset_line

Offset a line by a distance.

offset_polygon

Offset a polygon (closed) by a distance.

offset_polyline

Offset a polyline by a distance.

orient_points

Orient points from one plane to another.

orthonormalize_axes

Corrects xaxis and yaxis to be unit vectors and orthonormal.

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.

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.

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.

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.

scale_points_xy

Scale points in the XY plane.

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.

sort_points

Sorts points of a pointcloud based on their distance from a given point.

sort_points_xy

Sorts points of a pointcloud based on their distance from a given point, assuming all points 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.

tangent_points_to_circle_xy

Calculates the tangent points on a circle in the XY plane.

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.

translate_points

Translate points.

translate_points_xy

Translate points and in the XY plane.

translation_from_matrix

Returns the 3 values of translation from the matrix M.

transpose_matrix

Transpose a matrix.

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.

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.

volume_polyhedron

Compute the volume of a polyhedron represented by a closed mesh.

world_to_local_coordinates

Convert global coordinates to local coordinates.

Functions using Numpy

In environments where numpy is not available, these functions can still be accessed through RPC.

bestfit_circle_numpy

Fit a circle through a set of points.

bestfit_frame_numpy

Fit a frame to a set of points.

bestfit_line_numpy

Fit a line through 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.

closest_points_in_cloud_numpy

Find the closest points in a point cloud to a set of sample 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.

dehomogenize_and_unflatten_frames_numpy

Dehomogenize a list of vectors and unflatten the 2D list into a 3D list.

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

homogenize_numpy

Dehomogenizes points or vectors.

icp_numpy

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

local_to_world_coordinates_numpy

Convert local coordinates to global (world) coordinates.

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.

pca_numpy

Compute the principle components of a set of data points.

transform_points_numpy

Transform multiple points with one Transformation using numpy.

transform_vectors_numpy

Transform multiple vectors with one Transformation using numpy.

trimesh_descent_numpy

Compute the descent directions of a triangular mesh as the gradient of the vertex heights.

trimesh_gradient_numpy

Construct the gradient operator of a trianglular mesh.

world_to_local_coordinates_numpy

Convert global coordinates to local coordinates.

Pluggables

Pluggables are functions that don’t have an actual implementation, but receive an implementation from a plugin.

boolean_difference_mesh_mesh

Compute the boolean difference of two triangle meshes.

boolean_difference_polygon_polygon

Compute the boolean difference of two polygons.

boolean_intersection_mesh_mesh

Compute the boolean intersection of two triangle meshes.

boolean_intersection_polygon_polygon

Compute the boolean intersection of two polygons.

boolean_symmetric_difference_polygon_polygon

Compute the boolean symmetric difference of two polygons.

boolean_union_mesh_mesh

Compute the boolean union of two triangle meshes.

boolean_union_polygon_polygon

Compute the boolean union of two polygons.

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_triangulation

Construct a Delaunay triangulation of set of vertices.

intersection_mesh_mesh

Compute the intersection of two meshes.

intersection_ray_mesh

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

oriented_bounding_box

Computes the oriented minimum bounding box of a list of points.

quadmesh_planarize

Planarize the faces of a quad mesh.

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_mean_curvature

Compute the discrete mean curvature of a triangle mesh.

trimesh_principal_curvature

Compute the principal curvature directions of a triangle mesh.

trimesh_remesh

Remeshing of a triangle mesh.

trimesh_remesh_along_isoline

Remesh a mesh along an isoline of a scalarfield over the vertices.

trimesh_remesh_constrained

Constrained remeshing of a triangle mesh.

trimesh_slice

Slice a mesh by a list of planes.