Skip to content

Add Circle type#258

Open
gpeairs wants to merge 3 commits into
mainfrom
gp/issue-251
Open

Add Circle type#258
gpeairs wants to merge 3 commits into
mainfrom
gp/issue-251

Conversation

@gpeairs

@gpeairs gpeairs commented Jul 13, 2026

Copy link
Copy Markdown
Member

Close #251. Adds AbstractEllipse abstract type and makes both Ellipse and new Circle concrete subtypes. This allows Circle methods to take fast paths, as well as participate in curve recovery by resolving to a CurvilinearPolygon with four 90 degree arcs. (CurvilinearPolygon doesn't like single closed curves (see #256), and SolidModel wants arcs strictly less than 180 degrees anyway; four arcs is also nice because it's equivalent to a fully rounded square.)

Circle{T} stores center and radius directly instead of constructing an
equal-radii Ellipse. Shared behavior (perimeter, SolidModel
primitive rendering, mesh sizing) moves to a new AbstractEllipse supertype
dispatching through the center/r1/r2/angle accessors; `to_polygons` calls
`circular_arc` directly (rendered geometry is equivalent within tolerance).
Angle-preserving transformations return a
Circle; general transformations still widen to Ellipse. Adds bounds and
perimeter fast paths for Circle.

Breaking for consumers of internals: Circle constructors no longer
return Ellipse; code relying on `Circle(...) isa Ellipse` should use
AbstractEllipse and direct field access should be replaced with
accessors.

Represent Circle exactly as four arcs for curve recovery

A new CurvilinearPolygon(::Circle) constructor builds the circle from four
90-degree Turn arcs meeting at the axis-aligned extreme points, avoiding the
degeneracies of single-curve (constructor dedup, zero-length assert, mod2pi
collapse) and semicircle (OCC split path, collinear-endpoint guard) forms.
Circles now participate in curve recovery through both the unstyled clip path
(_normalize_curved_clip_arg) and the styled path (to_curvilinear), recovering
their arcs through boolean operations instead of warning and discretizing.
Ellipse behavior is unchanged (unequal radii are not representable as arcs).
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@gpeairs

gpeairs commented Jul 16, 2026

Copy link
Copy Markdown
Member Author

This is breaking for anything downstream that assumes the output of Circle or coordinate transformation of it isa Ellipse. Do we consider that that API/promise-breaking (needs major version bump) or internal? The Circle docs say "Construct an Ellipse with major and minor radii equal to r at center (or origin if not provided)." I think if we do this we want to say it's breaking, so the question is whether we want to do it (now or at all). I'm leaning no, there's a better way.

The main thing we want is for circles to participate in curve recovery, and the rendering shortcut is also nice. But we can just check if the radii are (exactly) equal when we want special handling of circles. This isn't measurably worse performance-wise than using dispatch, and actually avoids the instability for generic transformations and (potentially) one more type for union splitting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Circle type

1 participant