Currently, we have a specialized CirclesArray that manages (x, y, r) with a SoA layout. While efficient, this design doesn’t scale well to other shapes (e.g., ellipses, rectangles). We should introduce a generalized GShapesArray base class to unify the handling of homogeneous shape arrays while maintaining vectorized performance.
Proposed design:
-
Create GShapesArray as a generic container with three clear components:
- Positional parameters:
(x, y) in 2D, (x, y, z) in 3D.
- Orientation parameters:
θ in 2D, (azimuth, polar) in 3D.
- Size parameters: shape-specific (e.g.,
r for circles, (a, b) for ellipses, (w, h) for rectangles).
-
Implement shared vectorized operations at the base level:
translate(dx, dy, dz=0)
rotate(angle, pivot) (2D) / spherical rotations (3D)
scale(factor)
bounding_box()
-
Specialized subclasses (CirclesArray, EllipsesArray, etc.) extend this by:
- Defining the schema of
sizes
- Implementing shape-specific operations (
areas(), perimeters(), contains(), etc.)
Benefits:
- Clean separation of position/orientation vs. size.
- Consistent interface across all shapes.
- Easy extensibility for new shape families.
- Reuse of optimized vectorized transformations.
Action items:
Currently, we have a specialized
CirclesArraythat manages(x, y, r)with a SoA layout. While efficient, this design doesn’t scale well to other shapes (e.g., ellipses, rectangles). We should introduce a generalizedGShapesArraybase class to unify the handling of homogeneous shape arrays while maintaining vectorized performance.Proposed design:
Create
GShapesArrayas a generic container with three clear components:(x, y)in 2D,(x, y, z)in 3D.θin 2D,(azimuth, polar)in 3D.rfor circles,(a, b)for ellipses,(w, h)for rectangles).Implement shared vectorized operations at the base level:
translate(dx, dy, dz=0)rotate(angle, pivot)(2D) / spherical rotations (3D)scale(factor)bounding_box()Specialized subclasses (
CirclesArray,EllipsesArray, etc.) extend this by:sizesareas(),perimeters(),contains(), etc.)Benefits:
Action items:
GShapesArraybase class with generic storage and transforms.CirclesArrayto inherit fromGShapesArray.EllipsesArrayprototype as proof-of-concept.CirclesArray.