bool LineSegment::project(const LineSegment& seg, LineSegment& ret) const { double pf0=projectionFactor(seg.p0); double pf1=projectionFactor(seg.p1); // check if segment projects at all if (pf0>=1.0 && pf1>=1.0) return false; if (pf0<=0.0 && pf1<=0.0) return false; Coordinate newp0; project(seg.p0, newp0); Coordinate newp1; project(seg.p1, newp1); ret.setCoordinates(newp0, newp1); return true; }