public override Vector3 Interpolate(float value, int currentControlPoint) { if (currentControlPoint + 3 >= _myPoints.Count) { return(_myPoints[currentControlPoint]); } return(CCVector3.BezierPoint(_myPoints[currentControlPoint], _myPoints[currentControlPoint + 1], _myPoints[currentControlPoint + 2], _myPoints[currentControlPoint + 3], value)); }
/// <summary> /// Compute the length on a bezier spline between control point 1 and 2 </summary> /// <param name="theP0"> control point 0 </param> /// <param name="theP1"> control point 1 </param> /// <param name="theP2"> control point 2 </param> /// <param name="theP3"> control point 3 </param> /// <returns> the length of the segment </returns> public static float BezierLength(Vector3 theP0, Vector3 theP1, Vector3 theP2, Vector3 theP3) { float delta = 0.01f, t = 0.0f, result = 0.0f; Vector3 v1 = theP0, v2 = new Vector3(); while (t <= 1.0f) { v2 = CCVector3.BezierPoint(theP0, theP1, theP2, theP3, t); result += Vector3.Distance(v1, v2); v1.Set(v2.x, v2.y, v2.z); t += delta; } return(result); }