mirror of
git://projects.qi-hardware.com/cae-tools.git
synced 2024-12-22 23:04:16 +02:00
poly2d/p2d_attrib.c (angle_3): don't divide by zero ...
This broke p2d_is_cw which in turn tripped CGAL::create_interior_skeleton_and_offset_polygons_with_holes_2 with the infamous terminate called after throwing an instance of 'CGAL::Assertion_exception' what(): CGAL ERROR: assertion violation! Expr: lParent File: /usr/include/CGAL/arrange_offset_polygons_2.h Line: 94
This commit is contained in:
parent
05d3d50421
commit
7ca942d0e9
@ -28,19 +28,23 @@ static double angle_3(const struct v2d *a, const struct v2d *b,
|
||||
{
|
||||
double ax, ay, bx, by;
|
||||
double aa, bb;
|
||||
double angle;
|
||||
double cross, angle;
|
||||
|
||||
ax = b->x - a->x;
|
||||
ay = b->y - a->y;
|
||||
bx = c->x - b->x;
|
||||
by = c->y - b->y;
|
||||
|
||||
cross = ax * by - ay * bx;
|
||||
if (!cross)
|
||||
return 0;
|
||||
|
||||
aa = hypot(ax, ay);
|
||||
bb = hypot(bx, by);
|
||||
|
||||
angle = acos((ax * bx + ay * by) / aa / bb) / M_PI * 180.0;
|
||||
|
||||
return ax * by - ay * bx >= 0 ? angle : -angle;
|
||||
return cross >= 0 ? angle : -angle;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user