Zum Hauptinhalt springen

raygeo.geo.shape.polygon3d

Functions

flip_polygon_3d()

flip_polygon_3d(
polygon: Sequence[types.Point3D],
flip_h: bool = False,
flip_v: bool = False,
flip_z: bool = False,
) -> types.Polygon3D

Flip a 3D polygon horizontally, vertically, and/or along Z.

ParameterTypeDescription
polygonSequence[types.Point3D]Polygon as (x, y, z) points.
flip_hbool = FalseWhether to flip horizontally (negate X).
flip_vbool = FalseWhether to flip vertically (negate Y).
flip_zbool = FalseWhether to flip along Z (negate Z).
Returnstypes.Polygon3DFlipped polygon.
ComplexityO(n)

3D polygon flipped horizontally and along Z

3D polygon flipped horizontally and along Z

flip_polygons_3d()

flip_polygons_3d(
polygons: Any,
flip_h: bool = False,
flip_v: bool = False,
flip_z: bool = False,
) -> list[types.Polygon3D]

Flip multiple 3D polygons.

ParameterTypeDescription
polygonsAnyList of 3D polygons.
flip_hbool = FalseWhether to flip horizontally (negate X).
flip_vbool = FalseWhether to flip vertically (negate Y).
flip_zbool = FalseWhether to flip along Z (negate Z).
Returnslist[types.Polygon3D]Flipped polygons.
ComplexityO(n * m)

get_polygon_bounds_3d()

get_polygon_bounds_3d(polygon: Sequence[types.Point3D]) -> types.Rect3D

Get the 3D bounding box of a polygon.

ParameterTypeDescription
polygonSequence[types.Point3D]Polygon as (x, y, z) points.
Returnstypes.Rect3DBounding box as (x_min, y_min, x_max, y_max, z_min, z_max).
ComplexityO(n)

3D bounding box (Rect3D)

3D bounding box (Rect3D)

get_polygon_centroid_3d()

get_polygon_centroid_3d(polygon: Sequence[types.Point3D]) -> types.Point3D

Get the centroid of a 3D polygon.

XY centroid from shoelace formula, Z from average.

ParameterTypeDescription
polygonSequence[types.Point3D]Polygon as (x, y, z) points.
Returnstypes.Point3DCentroid point (x, y, z).
ComplexityO(n)

3D centroid – XY via shoelace, Z as average

3D centroid – XY via shoelace, Z as average

get_polygon_convex_hull_3d()

get_polygon_convex_hull_3d(polygon: Sequence[types.Point3D]) -> types.Polygon3D

Get the convex hull of a 3D polygon (XY-plane, Z from first vertex).

ParameterTypeDescription
polygonSequence[types.Point3D]Polygon as (x, y, z) points.
Returnstypes.Polygon3DConvex hull as list of (x, y, z) points.
ComplexityO(n log n)

3D convex hull (XY-plane, Z from first hull vertex)

3D convex hull (XY-plane, Z from first hull vertex)

get_polygon_edges_3d()

get_polygon_edges_3d(
polygon: Sequence[types.Point3D],
) -> list[tuple[types.Point3D, types.Point3D]]

Get the edges of a 3D polygon.

ParameterTypeDescription
polygonSequence[types.Point3D]Polygon as (x, y, z) points.
Returnslist[tuple[types.Point3D, types.Point3D]]List of ((x1, y1, z1), (x2, y2, z2)) edges.
ComplexityO(n)

3D polygon edges as (start, end) pairs

3D polygon edges as (start, end) pairs

get_polygon_group_bounds_3d()

get_polygon_group_bounds_3d(polygons: Any) -> types.Rect3D

Get the 3D bounding box of a group of polygons.

ParameterTypeDescription
polygonsAnyList of 3D polygons.
Returnstypes.Rect3DBounding box as (x_min, y_min, x_max, y_max, z_min, z_max).
ComplexityO(n * m)

get_polygon_perimeter_3d()

get_polygon_perimeter_3d(polygon: Sequence[types.Point3D]) -> float

Get the perimeter of a 3D polygon using full 3D edge lengths.

ParameterTypeDescription
polygonSequence[types.Point3D]Polygon as (x, y, z) points.
ReturnsfloatPerimeter length.
ComplexityO(n)

3D polygon perimeter using full 3D edge lengths

3D polygon perimeter using full 3D edge lengths

get_polygons_difference_3d()

get_polygons_difference_3d(poly1: Any, poly2: Any) -> list[types.Polygon3D]

Compute the difference of two 3D polygons (poly1 - poly2).

ParameterTypeDescription
poly1AnySubject 3D polygon.
poly2AnyClip 3D polygon.
Returnslist[types.Polygon3D]Difference result with Z from first polygon.

3D polygon difference (A − B) — Z from A

3D polygon difference (A − B) — Z from A

get_polygons_group_difference_3d()

get_polygons_group_difference_3d(
subject: Any,
clip: Any,
) -> list[types.Polygon3D]

Group difference of 3D polygons (subject - clip).

ParameterTypeDescription
subjectAnySubject group of 3D polygons.
clipAnyClip group of 3D polygons.
Returnslist[types.Polygon3D]Difference result with Z from first subject polygon.

get_polygons_group_intersection_3d()

get_polygons_group_intersection_3d(
subject: Any,
clip: Any,
) -> list[types.Polygon3D]

Group intersection of 3D polygons (subject ∩ clip).

ParameterTypeDescription
subjectAnySubject group of 3D polygons.
clipAnyClip group of 3D polygons.
Returnslist[types.Polygon3D]Intersection result with Z from first subject polygon.

get_polygons_intersection_3d()

get_polygons_intersection_3d(poly1: Any, poly2: Any) -> list[types.Polygon3D]

Compute the intersection of two 3D polygons (XY-plane, Z preserved).

ParameterTypeDescription
poly1AnyFirst 3D polygon.
poly2AnySecond 3D polygon.
Returnslist[types.Polygon3D]Intersection result with Z from first polygon.

3D polygon intersection — Z from first polygon

3D polygon intersection — Z from first polygon

get_polygons_union_3d()

get_polygons_union_3d(polygons: Any) -> list[types.Polygon3D]

Compute the union of 3D polygons (XY-plane, Z preserved).

ParameterTypeDescription
polygonsAnyList of 3D polygons.
Returnslist[types.Polygon3D]Union result with Z from first polygon.

3D polygon union — Z from first polygon

3D polygon union — Z from first polygon

offset_polygon_3d()

offset_polygon_3d(polygon: Any, offset: float) -> list[types.Polygon3D]

Offset (inflate/deflate) a closed 3D polygon.

ParameterTypeDescription
polygonAnyInput 3D polygon.
offsetfloatOffset distance (positive = grow, negative = shrink).
Returnslist[types.Polygon3D]Offset polygons with Z from input.

3D polygon offset — Z preserved from input

3D polygon offset — Z preserved from input

offset_polyline_3d()

offset_polyline_3d(
polyline: Sequence[types.Point3D],
distance: float,
closed: bool = False,
) -> types.Polygon3D

Offset a 3D polyline in true 3D (edge-plane miter).

Unlike offset_polygon_3d (which projects to XY, offsets, then lifts back), this function offsets each vertex in the local plane of its two adjacent edges. This gives a true 3D offset suitable for non-planar polylines.

Positive distance offsets to the left of the traversal direction.

ParameterTypeDescription
polylineSequence[types.Point3D]Input 3D vertices as (x, y, z) points.
distancefloatOffset distance (positive = left, negative = right).
closedbool = FalseWhen True, the polyline is treated as a closed ring (last vertex connects back to first). When False (default), the first and last vertices are offset perpendicular to their single edge.
Returnstypes.Polygon3DOffset polyline with the same number of vertices.
ComplexityO(n)

True 3D polyline offset (edge-plane miter)

True 3D polyline offset (edge-plane miter)

rotate_polygon_3d()

rotate_polygon_3d(
polygon: Sequence[types.Point3D],
angle: float,
) -> types.Polygon3D

Rotate a 3D polygon around the Z axis (XY rotation, Z preserved).

ParameterTypeDescription
polygonSequence[types.Point3D]Polygon as (x, y, z) points.
anglefloatRotation angle in degrees.
Returnstypes.Polygon3DRotated polygon.
ComplexityO(n)

3D polygon rotated around Z axis (Z preserved)

3D polygon rotated around Z axis (Z preserved)

rotate_polygons_3d()

rotate_polygons_3d(polygons: Any, angle: float) -> list[types.Polygon3D]

Rotate multiple 3D polygons around the Z axis.

ParameterTypeDescription
polygonsAnyList of 3D polygons.
anglefloatRotation angle in degrees.
Returnslist[types.Polygon3D]Rotated polygons.
ComplexityO(n * m)

scale_polygon_3d()

scale_polygon_3d(
polygon: Sequence[types.Point3D],
scale: float,
scale_y: Optional[float] = None,
scale_z: Optional[float] = None,
) -> types.Polygon3D

Scale a 3D polygon.

ParameterTypeDescription
polygonSequence[types.Point3D]Polygon as (x, y, z) points.
scalefloatX (and Y/Z if scale_y/scale_z are None) scale factor.
scale_yOptional[float] = NoneY scale factor (optional).
scale_zOptional[float] = NoneZ scale factor (optional).
Returnstypes.Polygon3DScaled polygon.
ComplexityO(n)

3D polygon scaled uniformly

3D polygon scaled uniformly

translate_polygon_3d()

translate_polygon_3d(
polygon: Sequence[types.Point3D],
dx: float,
dy: float,
dz: float = 0,
) -> types.Polygon3D

Translate a 3D polygon.

ParameterTypeDescription
polygonSequence[types.Point3D]Polygon as (x, y, z) points.
dxfloatX translation.
dyfloatY translation.
dzfloat = 0Z translation.
Returnstypes.Polygon3DTranslated polygon.
ComplexityO(n)

3D polygon translated by dx, dy, dz

3D polygon translated by dx, dy, dz

translate_polygons_3d()

translate_polygons_3d(
polygons: Any,
dx: float,
dy: float,
dz: float = 0,
) -> list[types.Polygon3D]

Translate a list of 3D polygons.

ParameterTypeDescription
polygonsAnyList of 3D polygons.
dxfloatX translation.
dyfloatY translation.
dzfloat = 0Z translation.
Returnslist[types.Polygon3D]Translated polygons.
ComplexityO(n * m)