-
Notifications
You must be signed in to change notification settings - Fork 27
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
2D polygon robustness #1493
base: develop
Are you sure you want to change the base?
2D polygon robustness #1493
Conversation
… plane segment intersection
Co-authored-by: Brad Whitlock <[email protected]>
…cting checks for robust unit test
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.
Thank you @bmhan12
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.
Thanks for fixing this so soon @bmhan12 !
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.
Thanks @bmhan12!
Please note the bugfix in the RELEASE-NOTES before merging
for(int i = 0; i < outputList.numVertices(); i++) | ||
{ | ||
int prevIndex = ((i - 1) == -1) ? (outputList.numVertices() - 1) : (i - 1); | ||
if(outputList[i] != outputList[prevIndex]) |
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.
I have a late follow-up question about this point test. Might tolerances need to apply here too? I ask because I tried the fixed code with 2 quads where the resulting output ought to be a triangle but it outputs a quad where the first 2 points are essentially the same.
void test4()
{
using Polygon = axom::primal::Polygon<double, 2>;
using Point = axom::primal::Point<double, 2>;
constexpr double eps = 1.e-6;
Polygon p1;
p1.addVertex(Point{0., 0.});
p1.addVertex(Point{1., 0.});
p1.addVertex(Point{1., 1.});
p1.addVertex(Point{0., 1.});
Polygon p2;
p2.addVertex(Point{0., 0.});
p2.addVertex(Point{0.3, 0.3});
p2.addVertex(Point{0., 1.});
p2.addVertex(Point{-0.3, 0.7});
const auto overlapPoly = axom::primal::clip(p1, p2, eps);
const auto area = overlapPoly.area();
std::cout << "subject=" << p1
<< ", clip=" << p2
<< ", overlap=" << overlapPoly
<< ", area=" << area
<< std::endl;
// Leads to a polygon with an extra vertex... area is good.
// subject={4-gon:(0,0),(1,0),(1,1),(0,1)}, clip={4-gon:(0,0),(0.3,0.3),(0,1),(-0.3,0.7)}, overlap={4-gon:(-6.66134e-17,1),(0,1),(0,0),(0.3,0.3)}, area=0.15
}
This PR:
intersect
overload between plane and segmentCloses #1481