Ported point_line_distance() and removed same_point()

This commit is contained in:
Alessandro Ranellucci 2013-11-06 23:08:03 +01:00
parent 09be25a156
commit c133a33ed2
6 changed files with 29 additions and 26 deletions

View file

@ -1,4 +1,5 @@
#include "Point.hpp"
#include "Line.hpp"
#include <math.h>
namespace Slic3r {
@ -72,6 +73,17 @@ Point::distance_to(const Point* point) const
return sqrt(dx*dx + dy*dy);
}
double
Point::distance_to(const Line* line) const
{
if (line->a.coincides_with(&line->b)) return this->distance_to(&line->a);
double n = (line->b.x - line->a.x) * (line->a.y - this->y)
- (line->a.x - this->x) * (line->b.y - line->a.y);
return abs(n) / line->length();
}
#ifdef SLIC3RXS
SV*
Point::to_SV_ref() {