Skip to content

Refactor CirclesArray into a generic GShapesArray framework #23

@338rajesh

Description

@338rajesh

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:

    1. Positional parameters: (x, y) in 2D, (x, y, z) in 3D.
    2. Orientation parameters: θ in 2D, (azimuth, polar) in 3D.
    3. 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:

  • Draft GShapesArray base class with generic storage and transforms.
  • Refactor CirclesArray to inherit from GShapesArray.
  • Add EllipsesArray prototype as proof-of-concept.
  • Update tests for unified API consistency.
  • Benchmark performance to ensure no regressions vs. current CirclesArray.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions