Permalink
Browse files

nicer interpolation

  • Loading branch information...
1 parent cde71b7 commit 5ef8c292350c0b136732f532994ab574a2b9712c @jdf committed Mar 1, 2009
Showing with 29 additions and 6 deletions.
  1. +6 −0 .project
  2. +7 −0 .pydevproject
  3. +13 −0 src/peasy/InterpolationUtil.java
  4. +3 −6 src/peasy/PeasyCam.java
View
@@ -5,6 +5,11 @@
<projects>
</projects>
<buildSpec>
+ <buildCommand>
+ <name>org.python.pydev.PyDevBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
@@ -13,5 +18,6 @@
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.python.pydev.pythonNature</nature>
</natures>
</projectDescription>
View
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?eclipse-pydev version="1.0"?>
+
+<pydev_project>
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.6</pydev_property>
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
+</pydev_project>
@@ -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;
View
@@ -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();
}

0 comments on commit 5ef8c29

Please sign in to comment.