compas_timber.geometry
¤
Classes¤
KDTree
¤
Wrapper around :class:scipy.spatial.KDTree that mimics the :class:compas.geometry.KDTree interface.
Parameters:
-
points(list[:class:`~compas.geometry.Point`]) –The points to build the tree from.
Source code in src/compas_timber/geometry.py
Methods:¤
nearest_neighbors
¤
Return the num nearest neighbours of point.
Parameters:
-
point(:class:`~compas.geometry.Point`) –The query point.
-
num(int) –The number of neighbours to return.
-
distance_sort(bool, default:True) –Unused - scipy always returns results sorted by distance.
Returns:
-
list[tuple[:class:`~compas.geometry.Point` | None, int | None, float]]–Each entry is
(point_or_None, index_or_None, distance). When fewer than num points are in the tree the missing entries carryNonefor both point and index andmath.inffor distance, matching the :class:compas.geometry.KDTreecontract.
Source code in src/compas_timber/geometry.py
query_pairs
¤
returns a list of pairs of indices of points in the tree that are within max_distance of each other.
Functions:¤
brep_difference_first
¤
Subtracts brep_b from brep_a and returns the first resulting piece.
Parameters:
-
brep_a(Brep) –The Brep to subtract from.
-
brep_b(Brep) –The Brep to subtract.
Returns:
-
The first resulting piece.–
Raises:
-
IndexError–If nothing is left of
brep_aafter the subtraction.
Source code in src/compas_timber/geometry.py
brep_from_outlines
¤
brep_from_outlines(
outline_a: Polyline, outline_b: Polyline, normal: Vector | None = None
) -> Brep
Create a solid brep from two closed outlines.
Assumes outline_a and outline_b are closed polylines with the same number of vertices. Assumes outlines are parallel to each other.
Parameters:
-
outline_a(Polyline) –The first closed outline.
-
outline_b(Polyline) –The second closed outline.
-
normal(Vector | None, default:None) –The normal vector around which the outlines are oriented.
Returns:
-
A Brep representing the solid defined by the two outlines.–
Raises:
-
ValueError–If either outline is not closed, if the outlines don't have the same number of vertices, or if the outlines are not parallel to each other.
Source code in src/compas_timber/geometry.py
brep_intersection_first
¤
Intersects brep_a with brep_b and returns the first resulting piece.
Parameters:
-
brep_a(Brep) –The first Brep.
-
brep_b(Brep) –The second Brep.
Returns:
-
The first resulting piece.–
Raises:
-
IndexError–If the two Breps do not overlap.
Source code in src/compas_timber/geometry.py
brep_union_first
¤
Unions brep_a with one or more other Breps and returns the first resulting piece.
Parameters:
-
brep_a(Brep) –The Brep to union with.
-
*breps(Brep, default:()) –One or more Breps to union with
brep_a.
Returns:
-
The first resulting piece.–
Raises:
-
IndexError–If the union left no result.
Source code in src/compas_timber/geometry.py
oriented_polyhedron
¤
oriented_polyhedron(polyhedron: Polyhedron) -> Polyhedron
Returns the polyhedron with consistently oriented faces.
This function ensures that the normals of the polyhedron's faces are all oriented outwards by reordering the vertex indices that define each face.
Parameters:
-
polyhedron(Polyhedron) –The input polyhedron.
Returns:
-
A new polyhedron with its faces reordered to ensure outward-facing normals.–
Source code in src/compas_timber/geometry.py
polyhedron_from_box_planes
¤
polyhedron_from_box_planes(
top_plane, bottom_plane, side_a_plane, side_b_plane, end_a_plane, end_b_plane
)
Create a hexahedral :class:~compas.geometry.Polyhedron defined by 6 bounding planes.
The geometry is equivalent to the intersection of three pairs of half-spaces. Vertices are computed as all 8 triple-plane intersections from the two top/bottom planes, two side planes, and two end planes.
Parameters:
-
top_plane(:class:`~compas.geometry.Plane`) –The plane forming the top face of the hexahedron.
-
bottom_plane(:class:`~compas.geometry.Plane`) –The plane forming the bottom face of the hexahedron.
-
side_a_plane(:class:`~compas.geometry.Plane`) –The plane forming one lateral side of the hexahedron.
-
side_b_plane(:class:`~compas.geometry.Plane`) –The plane forming the opposite lateral side of the hexahedron.
-
end_a_plane(:class:`~compas.geometry.Plane`) –The plane forming one end face of the hexahedron.
-
end_b_plane(:class:`~compas.geometry.Plane`) –The plane forming the opposite end face of the hexahedron.
Returns:
-
class:`~compas.geometry.Polyhedron`–A hexahedral polyhedron with 8 vertices and 6 faces.