Skip to content

Commit

Permalink
nicer interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Feinberg committed Mar 1, 2009
1 parent cde71b7 commit 5ef8c29
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -13,5 +18,6 @@
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.python.pydev.pythonNature</nature>
</natures>
</projectDescription>
7 changes: 7 additions & 0 deletions .pydevproject
Original file line number Diff line number Diff line change
@@ -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>
13 changes: 13 additions & 0 deletions src/peasy/InterpolationUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 3 additions & 6 deletions src/peasy/PeasyCam.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit 5ef8c29

Please sign in to comment.