diff --git a/.project b/.project index 99363e7..cc3e33b 100644 --- a/.project +++ b/.project @@ -5,6 +5,11 @@ + + org.python.pydev.PyDevBuilder + + + org.eclipse.jdt.core.javabuilder @@ -13,5 +18,6 @@ org.eclipse.jdt.core.javanature + org.python.pydev.pythonNature diff --git a/.pydevproject b/.pydevproject new file mode 100755 index 0000000..f47ecb1 --- /dev/null +++ b/.pydevproject @@ -0,0 +1,7 @@ + + + + +python 2.6 +Default + diff --git a/src/peasy/InterpolationUtil.java b/src/peasy/InterpolationUtil.java index 7a31042..5ee540e 100644 --- a/src/peasy/InterpolationUtil.java +++ b/src/peasy/InterpolationUtil.java @@ -46,6 +46,19 @@ static public Rotation slerp(final Rotation a, final Rotation b, final double t) * b.getQ3(), true); } + static public double smooth(final double a, final double b, final double t) + { + final double smooth = (t * t * (3 - 2 * t)); + return (b * smooth) + (a * (1 - smooth)); + + } + + static public Vector3D smooth(final Vector3D a, final Vector3D b, final double t) + { + return new Vector3D(smooth(a.getX(), b.getX(), t), smooth(a.getY(), b.getY(), t), + smooth(a.getZ(), b.getZ(), t)); + } + static public double linear(final double a, final double b, final double t) { return a + (b - a) * t; diff --git a/src/peasy/PeasyCam.java b/src/peasy/PeasyCam.java index 05d2e3e..e2d77aa 100644 --- a/src/peasy/PeasyCam.java +++ b/src/peasy/PeasyCam.java @@ -18,9 +18,6 @@ */ package peasy; -import static peasy.InterpolationUtil.linear; -import static peasy.InterpolationUtil.slerp; - import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; @@ -298,9 +295,9 @@ public void draw() } else { - rotation = slerp(startRotation, endRotation, t); - center = linear(startCenter, endCenter, t); - distance = linear(startDistance, endDistance, t); + rotation = InterpolationUtil.slerp(startRotation, endRotation, t); + center = InterpolationUtil.smooth(startCenter, endCenter, t); + distance = InterpolationUtil.smooth(startDistance, endDistance, t); } feed(); }