BezierInterpolator implements Interpolator<V> { @Override public V computeValue(double percent) { if (bezier == null) { bezier = getBezier(); } return bezier.pointAt(percent); } BezierInterpolator(V begin, V out, V in, V end); @Override V computeValue(double percent); void setControlPoints(V begin, V out, V in, V end); V getBegin(); void setBegin(V begin); V getOut(); void setOut(V out); V getIn(); void setIn(V in); V getEnd(); void setEnd(V end);  }
@Test public void testInterpolationV1() { Vector1 begin = new Vector1(0); Vector1 out = new Vector1(1); Vector1 in = new Vector1(9); Vector1 end = new Vector1(10); BezierInterpolator<Vector1> classToBeTested = new BezierInterpolator<Vector1>(begin, out, in, end); assertEqualsWithError(0.0, allowableError, classToBeTested.computeValue(0).x); assertEqualsWithError(10.0, allowableError, classToBeTested.computeValue(1).x); for (double percent = 0; percent <= 1.0; percent+=0.1) { classToBeTested.computeValue(percent); } }
@Test public void testInterpolationV2() { Vector2 begin = new Vector2(0,0); Vector2 out = new Vector2(0,100); Vector2 in = new Vector2(10,100); Vector2 end = new Vector2(10,0); BezierInterpolator<Vector2> classToBeTested = new BezierInterpolator<Vector2>(begin, out, in, end); assertEqualsWithError(0.0, allowableError, classToBeTested.computeValue(0).x); assertEqualsWithError(0.0, allowableError, classToBeTested.computeValue(0).y); assertEqualsWithError(10.0, allowableError, classToBeTested.computeValue(1).x); assertEqualsWithError(0.0, allowableError, classToBeTested.computeValue(1).y); for (double percent = 0; percent <= 1.0; percent+=0.01) { Vector2 computedValue = classToBeTested.computeValue(percent); } }
@Test public void testInterpolationTimeVector() { TimeVector begin = new TimeVector(0,0); TimeVector out = new TimeVector(0,100); TimeVector in = new TimeVector(10,100); TimeVector end = new TimeVector(10,0); BezierInterpolator<Vector2> classToBeTested = new BezierInterpolator<Vector2>(begin, out, in, end); assertEqualsWithError(0.0, allowableError, classToBeTested.computeValue(0).x); assertEqualsWithError(0.0, allowableError, classToBeTested.computeValue(0).y); assertEqualsWithError(10.0, allowableError, classToBeTested.computeValue(1).x); assertEqualsWithError(0.0, allowableError, classToBeTested.computeValue(1).y); for (double percent = 0; percent <= 1.0; percent+=0.01) { Vector2 computedValue = classToBeTested.computeValue(percent); } }
@Test public void testInterpolationV3() { Vector3 begin = new Vector3(0,0,0); Vector3 out = new Vector3(0,1,1); Vector3 in = new Vector3(10,1,2); Vector3 end = new Vector3(10,0,3); BezierInterpolator<Vector3> classToBeTested = new BezierInterpolator<Vector3>(begin, out, in, end); assertEqualsWithError(0.0, allowableError, classToBeTested.computeValue(0).x); assertEqualsWithError(0.0, allowableError, classToBeTested.computeValue(0).y); assertEqualsWithError(0.0, allowableError, classToBeTested.computeValue(0).z); assertEqualsWithError(10.0, allowableError, classToBeTested.computeValue(1).x); assertEqualsWithError(0.0, allowableError, classToBeTested.computeValue(1).y); assertEqualsWithError(3.0, allowableError, classToBeTested.computeValue(1).z); for (double percent = 0; percent <= 1.0; percent+=0.1) { classToBeTested.computeValue(percent); } }