-
Notifications
You must be signed in to change notification settings - Fork 37
Implemented ellipse-rectangle intersection test #3833
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -613,6 +613,53 @@ end | |
end | ||
end | ||
|
||
""" | ||
# Extended help | ||
|
||
isdisjoint(H::Hyperrectangle, E::Ellipsoid) | ||
|
||
### Algorithm | ||
|
||
The sets are disjoint if the ellipse center lies outside the Minkowski sum | ||
(rectangle expanded by the ellipsoid). Otherwise, we check one corner using | ||
a quadratic form derived from the ellipsoids support function. | ||
|
||
### Notes | ||
It works only for 2D axis-aligned rectangles and ellipsoids. | ||
|
||
### Reference | ||
David Eberly, “Distance Between a Point and an Ellipse, an Ellipsoid, or a Hyperellipsoid”, | ||
Geometric Tools, 2015. https://www.geometrictools.com/Documentation/DistancePointEllipseEllipsoid.pdf | ||
Comment on lines
+631
to
+632
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where exactly can I find the algorithm in that reference? |
||
""" | ||
|
||
@commutative function isdisjoint(H::Hyperrectangle, E::Ellipsoid) | ||
@assert dim(H) == dim(E) == 2 "$H and $E must both have 2 dimensions." | ||
|
||
# center to the origin | ||
H_trans = translate(H, -H.center) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You do not need |
||
E_trans = translate(E, -H.center) | ||
K = E_trans.center | ||
|
||
bbox = overapproximate(H_trans ⊕ E_trans, Hyperrectangle) | ||
if any(abs.(K) .> bbox.radius) | ||
return true | ||
end | ||
Comment on lines
+643
to
+646
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this first part necessary? It sounds more expensive to compute than the rest of the method. |
||
|
||
# find the rectangle corner corresponding to K. | ||
s = sign.(K) | ||
P = s .* H_trans.radius | ||
Δ = K - P | ||
|
||
# support vector on the boundary of E_trans in direction Δ. | ||
v = σ(Δ, E_trans) | ||
if any(s .* v .<= 0) | ||
return false | ||
end | ||
|
||
# check the ellipse condition | ||
return (ρ(Δ, E_trans))^2 ≤ 1 | ||
end | ||
|
||
# ============== # | ||
# disambiguation # | ||
# ============== # | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.