16 :
Line2D ( x0, y0, x1, y1, true )
35 return atan2 ( dy,dx );
56 return p0() == o.
p0() &&
p1() == o.
p1();
64 set ( p0.
x(), p0.
y(), p1.
x(), p1.
y() );
83 const double px =
x1()-
x0();
84 const double py =
y1()-
y0();
85 const double l2 = px*px + py*py;
86 double u = ( ( p.
x() -
x0() ) * px + ( p.
y() -
y0() ) * py ) / l2;
88 else if ( u < 0 ) u = 0;
89 const double xk =
x0() + u * px;
90 const double yk =
y0() + u * py;
93 return dx*dx + dy*dy ;
97 double px =
x1()-
x0();
98 double py =
y1()-
y0();
99 double l2 = px*px + py*py;
100 double u = ((p.
x() -
x0()) * px + (p.
y() -
y0()) * py) / l2;
102 else if (u < 0){ u = 0; }
106 double px =
x1()-
x0();
107 double py =
y1()-
y0();
double closestPointLineSegmentRatio(const Point2D &p) const
const double & y1() const
const double & x1() const
double distanceTo(const Point2D &p) const
bool operator==(const LineSegment2D &o) const
comparison operator
LineSegment2D()
the lines endpoints
const double length() const
Line2D & set(const double &x0, const double &y0, const double &x1, const double &y1, bool normalize=true)
const Line2D & line() const
Point2D closestPointTo(const Point2D &p) const
const double & y0() const
double distanceSqrTo(const Point2D &p, double &dx, double &dy) const
LineSegment2D & set(const double &x0, const double &y0, const double &x1, const double &y1)
const Point2D & p0() const
double distanceTo(const Point2D &p, double &dx, double &dy) const
const double & x0() const
Point2D & set(double x, double y)
const Point2D & p1() const