-
Notifications
You must be signed in to change notification settings - Fork 279
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
feat: provide a shapeDistance
function
#1328
Conversation
Deploying with Cloudflare Pages
|
± Registry diff
📊 PerformanceKeyNote that each bar component rounds up to the nearest 100ms, so each full bar is an overestimate by up to 400ms.
Data
|
Codecov Report
@@ Coverage Diff @@
## main #1328 +/- ##
==========================================
+ Coverage 61.40% 61.55% +0.14%
==========================================
Files 65 65
Lines 8056 8055 -1
Branches 1888 1884 -4
==========================================
+ Hits 4947 4958 +11
+ Misses 3001 2989 -12
Partials 108 108
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
@samestep, please describe what shapes this works on, what approximations (if any) are used, etc. in the PR description. |
@joshsunshine done! |
Description
This PR adds a new function called
shapeDistance
which computes the signed distance from the origin on the Minkowski sum of the first shape and the negative of the second shape.This works on all shapes. It uses the following approximations:
Circle
, we are exactRectlike
, we are exactText
orEquation
and the other isLine
, we use the bounding circle approximation added by @wodeni in feat: improveeuclidean.sty
#1117Polygonlike
, we use the intersection-of-half-planes approximation added by @jiriminarcik in feat: Line polygon constraints #810Rectlike
and the other isCircle
, we are exactPolygonlike
and the other isEllipse
, I'm not exactly sure what we do; @jiriminarcik do you happen to know if this is an approximation?Circle
and the other isLine
, I believe we are exactImplementation strategy and design decisions
I factored out most of the existing
overlapping
constraint. Also, for better typechecking, I added aShapeTuple
type representing the pair format expected by objectives and constraints, and ashapeTupleToShape
function that converts this to just aShape
. In the same file, I also addedRectlike
andPolygonlike
types along withisRectlike
andisPolygonlike
type predicates to go along with those.This patch made the
overlapping
constraint more correct for the case where one shape is a circle or an ellipse and the other is a rectangle, so I corrected the tests for that case.Checklist
Open questions
I didn't factor out the cases where one shape is an ellipse and the other is either a circle or an ellipse, because I don't know how to use our existing code to actually calculate the distance there.