Bezier implements Serializable { public V pointAt(double percent) { if (percent < 0 || percent > 1) { throw new IllegalArgumentException("Percent must be in range [0,1]. Value '" + percent + "' is illegal."); } int i = 0; while (i < percents.length - 1 && percents[i] <= percent) { i++; } double percentStart = i > 0 ? percents[i - 1] : 0d; double percentWindow = percents[i] - percentStart; double p = (percent - percentStart) / percentWindow; percent = (p + (double) i) / (double) numSubdivisions; return bezierPointAt(percent); } Bezier(V begin, V out, V in, V end);  Bezier(V begin, V out, V in, V end, int numSubdivisions); double getLength(); V pointAt(double percent); int getNumSubdivisions();  }
@Test public void testInterpolationV2() { Vector2 begin = new Vector2(0,0); Vector2 out = new Vector2(0,1); Vector2 in = new Vector2(10,1); Vector2 end = new Vector2(10,0); Bezier<Vector2> classToBeTested = new Bezier<Vector2>(begin, out, in, end); assertEquals(0.0, classToBeTested.pointAt(0).x, allowableError); assertEquals(0.0, classToBeTested.pointAt(0).y, allowableError); assertEquals(10.0, classToBeTested.pointAt(1).x, allowableError); assertEquals(0.0, classToBeTested.pointAt(1).y, allowableError); for (double percent = 0; percent <= 1.0; percent+=0.01) { Vector2 computedValue = classToBeTested.pointAt(percent); } }