/// <summary> /// Returns the instantaneous velocity given by 4 points and a time value. /// </summary> /// <param name="p0">The start point.</param> /// <param name="p1">The first control point.</param> /// <param name="p2">The second control point.</param> /// <param name="p3">The end point.</param> /// <param name="t">A value between 0 and 1.</param> public static Vector3 Velocity(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float t) { ArgumentChecker.CheckT(t); return((3f * (1f - t) * (1f - t) * (p1 - p0)) + (6f * (1f - t) * t * (p2 - p1)) + (3f * t * t * (p3 - p2))); }
/// <summary> /// Returns the curve coordinate given by 4 points and a time value. /// </summary> /// <param name="p0">The start point.</param> /// <param name="p1">The first control point.</param> /// <param name="p2">The second control point.</param> /// <param name="p3">The end point.</param> /// <param name="t">A value between 0 and 1.</param> public static Vector3 Point(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float t) { ArgumentChecker.CheckT(t); return(((1f - t) * (1f - t) * (1f - t) * p0) + (3f * (1f - t) * (1f - t) * t * p1) + (3f * (1f - t) * t * t * p2) + (t * t * t * p3)); }
/// <summary> /// Returns the instantaneous velocity given by 4 points and a normalized time value. /// </summary> /// <param name="p0">The start point.</param> /// <param name="p1">The first control point.</param> /// <param name="p2">The second control point.</param> /// <param name="p3">The end point.</param> /// <param name="t">A value between startTime and endTime.</param> /// <param name="startTime"></param> /// <param name="endTime"></param> public static Vector3 Velocity(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float t, float startTime, float endTime) { ArgumentChecker.CheckT(t, startTime, endTime); return(Velocity(p0, p1, p2, p3, TimeHelper.Normalized(t, startTime, endTime))); }