/** * A variation of Hermite where a velocity is given only for the first point. It interpolates P0 * at t=0 and P1 at t=1. P(t) = (t^2 - 2*t + 1) * P0 + (-t^2 + 2*t) * P1 + (t^2 - t) * T0 * * @param P0 * @param T0 * @param P1 * @param t * @return */ private static Vector3f quadraticHermite(Vector3f P0, Vector3f T0, Vector3f P1, float t) { float t2 = t * t; Vector3f P = new Vector3f(); P.scaleAdd(t2 - 2 * t + 1, P0, P); P.scaleAdd(-t2 + 2 * t, P1, P); P.scaleAdd(t2 - t, T0, P); return P; }
/** * Hermite interpolation of the points P0 to P1 at time t=0 to t=1 with the specified velocities * T0 and T1. * * @param P0 * @param T0 * @param P1 * @param T1 * @param t * @return */ private static Vector3f cubicHermite( Vector3f P0, Vector3f T0, Vector3f P1, Vector3f T1, float t) { float t2 = t * t; float t3 = t2 * t; Vector3f P = new Vector3f(); P.scaleAdd(2 * t3 - 3 * t2 + 1, P0, P); P.scaleAdd(t3 - 2 * t2 + t, T0, P); P.scaleAdd(-2 * t3 + 3 * t2, P1, P); P.scaleAdd(t3 - t2, T1, P); return P; }