geometry¤
Geometry functions on plain point lists: arrays of points, and projection onto and discretisation of polylines.
Arrays¤
circle_evaluate
¤
archimedean_spiral_evaluate
¤
Evaluate an archimedean spiral r = a + b * theta at angle t in radians.
Parameters:
-
t(float) –The angle in radians.
-
a(float) –The offset angle of the spiral.
-
b(float) –The radial growth per radian.
-
z(float, default:0) –The elevation of the spiral's plane above the XY plane.
Returns:
-
list–The XYZ coordinates of the point.
line_array
¤
rectangular_array
¤
rectangular_array(
nx: int, ny: int, dx: float, dy: float, anchor: list[float] = [0.0, 0.0, 0.0]
) -> list[list[float]]
circular_array
¤
spiral_array
¤
Polylines¤
polyline_length
¤
Total length of an OPEN polyline.
point_at_length
¤
point_at_length(
chain: list[list[float]], cumulative: list[float], s: float, tol: float = 1e-12
) -> list[float]
The point at arc length s along an open chain, by linear interpolation.
For a closed loop pass the ring (the loop with its first point repeated at
the end) and wrap s yourself. Beyond either end, the last point.
closest_on_polyline
¤
closest_on_polyline(
point: list[float], points: list[list[float]], closed: bool = False
) -> tuple[int, float, list[float], float]
(segment index, t, closest point, distance) on a polyline, in 3D.
Parameters:
-
point([x, y, z]) – -
points(list[[x, y, z]]) –Three components each; unlike the rest of this module,
zis read. -
closed(bool, default:False) –Add the segment from the last point back to the first.
Returns:
-
tuple–(index, t, [x, y, z], distance). Distance isinf, and the other three meaningless, when no segment has non-zero length.
project_on_polyline
¤
distance_to_polyline
¤
Shortest distance from a point to an OPEN polyline, in XY.
distance_to_loop
¤
near_loop
¤
near_loop(
points: list[list[float]], loop: list[list[float]], radius: float, chunk: int = 2048
) -> list[bool]
distance_to_loop(p, loop) < radius for many points at once, exactly.
loop_arc_lengths
¤
(segment lengths, cumulative arc length) of a CLOSED loop given open.
cumulative has one entry per vertex plus a last one, the loop's total
length, so segment i runs from cumulative[i] to cumulative[i + 1].
loop_parameter
¤
resample_loop
¤
One loop through discretise_boundary, with no scale rule.
discretise_line
¤
Discretise one open curve at spacing (thesis eq. 4.1), keeping its extremities.
Pass the wall spacing, or a 2-point guide never becomes a Delaunay edge.
Parameters:
-
line(list[[x, y, z]]) –The open curve.
-
spacing(float) –Maximum segment length.
Nonereturns the curve unchanged apart from dropping consecutive duplicates.
Returns:
-
list[[x, y, z]]–
discretise_boundary
¤
discretise_boundary(
outer: list[list[float]],
inners: list[list[list[float]]] | None = None,
alpha: float | None = 0.02,
d_min: int | None = 5,
spacing: float | None = None,
) -> tuple[list[list[float]], list[list[list[float]]]]
Discretise closed boundary loops per thesis eq. 4.1, d_i = max(ceil(l_i / (alpha D)), d_min).
Every input point survives; each segment is subdivided on its own.
Parameters:
-
outer(list[[x, y, z]]) –The outer loop, stored OPEN -- the last point is not the first. A repeated closing point is dropped, so a closed list is accepted too.
-
inners(list[list[[x, y, z]]], default:None) –The holes, same convention. They are discretised against the SAME
Das the outer loop, which is the point of taking them here rather than loop by loop: a small hole measured against its own bounding box would come back far denser than the wall beside it. -
alpha(float, default:0.02) –Fraction of
Dto use as the spacing whenspacingisNone.Nonefor both returns the loops unchanged -- the explicit opt-out, for a caller who has already sampled its walls. -
d_min(int, default:5) –Fewest points per loop, whatever the target length says.
Noneor0disables the floor. -
spacing(float, default:None) –Maximum segment length, given directly. Overrides
alphawhen notNone.
Returns:
-
tuple–(outer, inners), both open, with the closing segment subdivided like any other.
bounding_box_diagonal
¤
points_in_polygon_xy
¤
compas.geometry.is_point_in_polygon_xy for many points at once.
The same ray-crossing test with the same arithmetic, so every answer -- including a point exactly on an edge -- is the one compas gives.