Incomplete work for XS-based convex_hull

This commit is contained in:
Alessandro Ranellucci 2013-11-22 21:43:35 +01:00
parent a950fbe0c2
commit 4577f0725c
9 changed files with 38 additions and 28 deletions

View file

@ -90,6 +90,28 @@ Point::distance_to(const Line &line) const
return std::abs(n) / line.length();
}
/* Three points are a counter-clockwise turn if ccw > 0, clockwise if
* ccw < 0, and collinear if ccw = 0 because ccw is a determinant that
* gives the signed area of the triangle formed by p1, p2 and this point.
*/
double
Point::ccw(const Point &p1, const Point &p2) const
{
return (p2.x - p1.x)*(this->y - p1.y) - (p2.y - p1.y)*(this->x - p1.x);
}
double
Point::ccw(const Point* p1, const Point* p2) const
{
return this->ccw(*p1, *p2);
}
double
Point::ccw(const Line &line) const
{
return this->ccw(line.a, line.b);
}
#ifdef SLIC3RXS
SV*
Point::to_SV_ref() {

View file

@ -26,6 +26,9 @@ class Point
double distance_to(const Point* point) const;
double distance_to(const Line* line) const;
double distance_to(const Line &line) const;
double ccw(const Point &p1, const Point &p2) const;
double ccw(const Point* p1, const Point* p2) const;
double ccw(const Line &line) const;
#ifdef SLIC3RXS
void from_SV(SV* point_sv);