Interpolates between the given two values with their associated tangents using hermite interpolation. @param v0 the first value @param t0 the tangent of the first value @param v1 the second value @param t1 the tangent of the second value @param t the interpolation parameter, within [0..1]
(double v0, double t0, double v1, double t1, double t)
| 40 | * @return the interpolated value |
| 41 | */ |
| 42 | public static double hermite(double v0, double t0, double v1, double t1, double t) { |
| 43 | double t2 = t * t; |
| 44 | double t3 = t2 * t; |
| 45 | double result; |
| 46 | if (t == 0.0) result = v0; |
| 47 | else if (t == 1.0) result = v1; |
| 48 | else result = (2.0 * v0 - 2.0 * v1 + t1 + t0) * t3 + (3.0 * v1 - 3.0 * v0 - 2.0 * t0 - t1) * t2 + t0 * t + v0; |
| 49 | return result; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Uses hermite interpolation with zero tangents to produce smooth values between <code>v1</code> and <code>v2</code> based on the value of <code>t</code>. |
no outgoing calls
no test coverage detected