mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-09 14:55:08 -06:00
Ported point_line_distance() and removed same_point()
This commit is contained in:
parent
09be25a156
commit
c133a33ed2
6 changed files with 29 additions and 26 deletions
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue