Move arc_radius to ShapeElement::radius and use it throughout - #52
Merged
Conversation
Turns the free helper (only used in basic_shapes.cpp) into a proper ShapeElement member, so it's usable everywhere a CircularArc's radius is needed and throws if called on a non-arc element instead of silently computing a meaningless distance. Replace every distance(center, start) radius computation across shape.cpp, offset.cpp, no_fit_polygon.cpp, simplification.cpp, supports.cpp, and elements_intersections.cpp with .radius(), inlining the call where the result was only used once. The squared_distance radius comparisons in elements_intersections.cpp are left as-is: they intentionally avoid a sqrt and compare at a different tolerance scale, so they aren't equivalent to .radius().
fontanf
force-pushed
the
shape-element-radius
branch
from
July 31, 2026 12:05
825a2b6 to
b15b789
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ShapeElement::radius(), throwingstd::invalid_argumentif the element isn't aCircularArc, replacing the freearc_radiushelper that was only used inbasic_shapes.cpp.distance(center, start)-style radius computations with.radius()throughoutshape.cpp,offset.cpp,no_fit_polygon.cpp,simplification.cpp,supports.cpp, andelements_intersections.cpp, inlining the call at sites where the result was only used once.squared_distance-based radius comparisons inelements_intersections.cppuntouched, since they intentionally avoid asqrtand compare at a different tolerance scale.Test plan
./build_claude/test/Shape_shape_test— full suite, 459/459 pass