Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

nicer interpolation

  • Loading branch information...
commit 5ef8c292350c0b136732f532994ab574a2b9712c 1 parent cde71b7
@jdf authored
View
6 .project
@@ -6,6 +6,11 @@
</projects>
<buildSpec>
<buildCommand>
+ <name>org.python.pydev.PyDevBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
@@ -13,5 +18,6 @@
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.python.pydev.pythonNature</nature>
</natures>
</projectDescription>
View
7 .pydevproject
@@ -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>
View
13 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;
View
9 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();
}
Please sign in to comment.
Something went wrong with that request. Please try again.