Rigid Body Transformations (transform.py)¶
The transform module provides 2D rigid body affine transformation utilities (translation, rotation, scaling) operating directly on CGAL geometric primitives (Point_2, Polygon_2, Segment_2).
Architectural Role¶
Robot Motion Simulation: Transforms robot geometry (polygons, discs, segments) from reference body frame coordinates to global world frame coordinates during planning and path validation.
Minkowski Sum Transformations: Inverts robot polygons around the origin for Minkowski difference calculations in
ExactSingle.Exact Arithmetic Transformations: Uses CGAL
Aff_transformation_2andRotationmatrices wrapped with exact field types (FT), preventing numerical drift.
Key Transformation Functions¶
translate_point(p, dx, dy): Translates aPoint_2by displacement vector
.translate_polygon(poly, dx, dy): Translates all vertices of aPolygon_2.rotate_polygon(poly, angle, center): Rotates a polygon by
radians around a center pivot point.scale_polygon(poly, scale_x, scale_y): Applies non-uniform scaling to polygon vertices.
Usage Example¶
from discopygal.geometry_utils import transform
from discopygal.bindings import Point_2, FT
# Translate a polygon robot by (dx=3.0, dy=-1.5)
translated_poly = transform.translate_polygon(robot_poly, FT(3.0), FT(-1.5))
# Rotate around origin by 45 degrees (pi/4)
rotated_poly = transform.rotate_polygon(robot_poly, math.pi / 4)