mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-19 20:57:53 -06:00
New +Line::intersection_infinite() method
This commit is contained in:
parent
aa69ae11a8
commit
e749f6040f
4 changed files with 33 additions and 1 deletions
|
@ -89,6 +89,23 @@ Line::point_at(double distance) const
|
|||
return p;
|
||||
}
|
||||
|
||||
bool
|
||||
Line::intersection_infinite(const Line &other, Point* point) const
|
||||
{
|
||||
Vector x = this->a.vector_to(other.a);
|
||||
Vector d1 = this->vector();
|
||||
Vector d2 = other.vector();
|
||||
|
||||
double cross = d1.x * d2.y - d1.y * d2.x;
|
||||
if (std::fabs(cross) < EPSILON)
|
||||
return false;
|
||||
|
||||
double t1 = (x.x * d2.y - x.y * d2.x)/cross;
|
||||
point->x = this->a.x + d1.x * t1;
|
||||
point->y = this->a.y + d1.y * t1;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
Line::coincides_with(const Line &line) const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue