/** * Inserts a git point at the point on the spline closest to the given position. */ void RSpline::insertFitPointAt(const RVector& point) { RVector p = getClosestPointOnShape(point); // find out T at the point closest to point: double t = getTAtPoint(p); // find out index of fit point before t: int index = -1; for (int i=0; i<fitPoints.length(); i++) { double tc = getTAtPoint(fitPoints[i]); if (i==0 && isClosed()) { // closed spline: two t's for first fit point: tc = 0.0; } //qWarning() << "tc: " << tc; if (tc<t) { index = i+1; } else { break; } } // point not on spline: if (index<0 || index>=fitPoints.length()) { if (isClosed()) { index = 0; } else { qWarning() << "no point on spline found. t: " << t; return; } } fitPoints.insert(index, p); update(); }
void RRay::trimEndPoint(const RVector& p) { RVector tp = getClosestPointOnShape(p, false); directionVector = tp - basePoint; }