-
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: compute rect-line distance exactly #1332
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1332 +/- ##
==========================================
+ Coverage 61.55% 61.89% +0.33%
==========================================
Files 65 65
Lines 8055 8103 +48
Branches 1884 1887 +3
==========================================
+ Hits 4958 5015 +57
+ Misses 2989 2980 -9
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. |
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
|
After reading the code, it looks like the |
@joshsunshine No, that is not correct: penrose/packages/core/src/contrib/Queries.ts Line 275 in af2f8b5
|
I am glad I asked. Why didn't you add |
Nope, no reason not to do that! Do you want me to do it in this PR, or in a followup? |
This PR. |
@joshsunshine Done. |
Description
This PR provides a
rectLineDist
function which differentiably computes the exact signed distance from the origin to the Minkowski difference of a rectangle and a line, and modifies the implementation of theshapeDistance
function added by #1328 to use this when one shape is aLine
and the other is anEquation
orText
(as opposed to the previous implementation, which used a bounding circle as an approximation instead of a bounding box). I also added a new example to the registry to demonstrate visually that this works.Implementation strategy and design decisions
The reason to export a new
rectLineDist
function, instead of just usingshapeDistance
, is that sometimes we want to phrase an objective or constraint as if something is a straight line segment, even if the actual shape being drawn is something else, like a quadratic Bézier curve in the case of #1317. UsingshapeDistance
requires you to actually have a genuineLine
shape in the diagram.Also, we didn't have an
xor
autodiff function before, so I added one here. While I was doing that, I noticed that some comments in the autodiff types file were out of date, so I updated them.I changed the variation for
parallel-lines-euclidean
because for some reason this patch was causing it to take a long time to optimize (almost ten seconds) with the old variation.Checklist