MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / hermite

Method hermite

src/main/java/field/linalg/Interpolate.java:42–50  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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>.

Callers 4

hermiteMethod · 0.95
smoothStepMethod · 0.95
hermiteMethod · 0.95
hermiteMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected