-
- // Setup the derivative function
- etl::derivative<etl::hermite<Vector> > deriv(curve);
-
- int search_iterations(7);
-
- /*if(quality==0)search_iterations=8;
- else if(quality<=2)search_iterations=10;
- else if(quality<=4)search_iterations=8;
- */
- if(!perpendicular)
- {
- if(quality<=6)search_iterations=7;
- else if(quality<=7)search_iterations=6;
- else if(quality<=8)search_iterations=5;
- else search_iterations=4;
- }
- else
- {
- if(quality>7)
- search_iterations=4;
- }
-
- // Figure out the closest point on the curve
- const float t(curve.find_closest(point,search_iterations));
-
-
- // Calculate our values
- p1=curve(t);
- tangent=deriv(t).norm();
-
- if(perpendicular)
+
+ // Setup the derivative function
+ etl::derivative<etl::hermite<Vector> > deriv(curve);
+
+ int search_iterations(7);
+
+ /*if(quality==0)search_iterations=8;
+ else if(quality<=2)search_iterations=10;
+ else if(quality<=4)search_iterations=8;
+ */
+ if(perpendicular)
+ {
+ if(quality>7)
+ search_iterations=4;
+ }
+ else // not perpendicular
+ {
+ if(quality<=6)search_iterations=7;
+ else if(quality<=7)search_iterations=6;
+ else if(quality<=8)search_iterations=5;
+ else search_iterations=4;
+ }
+
+ // Figure out the closest point on the curve
+ if (fast)
+ t = curve.find_closest(fast, point,search_iterations);
+
+ // Calculate our values
+ p1=curve(t); // the closest point on the curve
+ tangent=deriv(t).norm(); // the unit tangent at that point
+
+ // if the point we're nearest to is at either end of the
+ // bline, our distance from the curve is the distance from the
+ // point on the curve. we need to know which side of the
+ // curve we're on, so find the average of the two tangents at
+ // this point
+ if (t<0.00001 || t>0.99999)
+ {
+ if (t<0.5)