Ported point_along_segment(), Polyline::length(), Polyline::clip_end() to XS

This commit is contained in:
Alessandro Ranellucci 2013-10-27 22:57:25 +01:00
parent 26a18a2a52
commit 29b83517cb
12 changed files with 64 additions and 57 deletions

View file

@ -42,6 +42,18 @@ Line::midpoint() const
return new Point ((this->a.x + this->b.x) / 2.0, (this->a.y + this->b.y) / 2.0);
}
Point*
Line::point_at(double distance) const
{
double len = this->length();
Point* p = new Point(this->a);
if (this->a.x != this->b.x)
p->x = this->a.x + (this->b.x - this->a.x) * distance / len;
if (this->a.y != this->b.y)
p->y = this->a.y + (this->b.y - this->a.y) * distance / len;
return p;
}
#ifdef SLIC3RXS
void
Line::from_SV(SV* line_sv)