Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Geometry circle methods #158

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

fiecueal
Copy link

A bunch of the new circle methods either work incorrectly or are inaccurate to the docs descriptions.

Fixed circle_intersect_line? and added ability to use anchor_(x|y).

rect_to_circle would either return the input object if a radius property exists or a new hash with {x:, y:, radius: }, neither of which are what the docs says it should return which is a rectangle. But that's also counterintuitive to the method name so I changed it to always return a new hash with {x:, y:, w:, h:, radius: } for consistency. I also removed the necessity for anchor_(x|y) with inputs without a radius while allowing any input to use anchor_(x|y).

To be honest, I just didn't know why rect? and circle? require truthy values for Hash inputs but only need respond_to? to be true for non Hash inputs and it bothered me so I simplified them.

Fixed intersect_circle? and removed the necessity for anchor_(x|y) with inputs without a radius while allowing any input to use anchor_(x|y).

when one or both circles increase to some size,
the method returns true even when no intersection is occuring;
removes unused resolved_circle_(one|two) vars;
properly handles anchor_(x|y);
removes necessity for anchor_(x|y) on args without radius;
uses the center points of the circles in distance_squared;
adds error message;
I didn't notice it was in the docs and removed it preemptively;
re-implemented to work more closely to the docs descriptions;
removes necessity for anchor_(x|y) on args without a radius;
allows anchor_(x|y) to work on args with a radius;
original implementation returns {x:, y:, radius:}
but the docs implies that what is returned is a rect,
re-implementation returns {x:, y:, w:, h:, radius:} for
the best of both worlds
utilize Geometry.rect_to_circle now that it works as intended
also adds anchor(x|y) functionality
end
shape.respond_to?(:x) &&
shape.respond_to?(:y) &&
shape.respond_to?(:radius)
Copy link

@Jealrock Jealrock Dec 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This returns true when passed shape is a Hash without radius key, so circle? would return true for a Hash describing rect.

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.

2 participants