j3d.org Code

org.j3d.util.interpolator
Class PositionInterpolator

java.lang.Object
  extended by org.j3d.util.interpolator.Interpolator
      extended by org.j3d.util.interpolator.PositionInterpolator

public class PositionInterpolator
extends Interpolator

An interpolator that works with positional coordinates.

The interpolation routine is just a simple linear interpolation between each of the points. The interpolator may take arbitrarily spaced keyframes and compute correct values.

Version:
$Revision: 1.5 $
Author:
Justin Couch

Field Summary
 
Fields inherited from class org.j3d.util.interpolator.Interpolator
allocatedSize, ARRAY_INCREMENT, currentSize, DEFAULT_SIZE, interpolationType, keys, LINEAR, STEP
 
Constructor Summary
PositionInterpolator()
          Create a new linear interpolator instance with the default size for the number of key values.
PositionInterpolator(int size)
          Create an linear interpolator with the given basic size.
PositionInterpolator(int size, int type)
          Create a interpolator with the given basic size using the interpolation type.
 
Method Summary
 void addKeyFrame(float key, float x, float y, float z)
          Add a key frame set of values at the given key point.
 void addKeyFrame(float key, javax.vecmath.Point3f pt)
          Add a key frame set of values at the given key point.
 float[] floatValue(float key)
          Get the interpolated value of the point at the given key value.
 javax.vecmath.Point3f pointValue(float key)
          Get the interpolated value of the point at the given key value.
 java.lang.String toString()
          Create a string representation of this interpolator's values
 
Methods inherited from class org.j3d.util.interpolator.Interpolator
clear, findKeyIndex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PositionInterpolator

public PositionInterpolator()
Create a new linear interpolator instance with the default size for the number of key values.


PositionInterpolator

public PositionInterpolator(int size)
Create an linear interpolator with the given basic size.

Parameters:
size - The starting number of items in interpolator

PositionInterpolator

public PositionInterpolator(int size,
                            int type)
Create a interpolator with the given basic size using the interpolation type.

Parameters:
size - The starting number of items in interpolator
type - The type of interpolation scheme to use
Method Detail

addKeyFrame

public void addKeyFrame(float key,
                        float x,
                        float y,
                        float z)
Add a key frame set of values at the given key point. This will insert the values at the correct position within the array for the given key. If two keys have the same value, the new key is inserted before the old one.

Parameters:
key - The value of the key to use
x - The x coordinate of the position at this key
y - The y coordinate of the position at this key
z - The z coordinate of the position at this key

addKeyFrame

public void addKeyFrame(float key,
                        javax.vecmath.Point3f pt)
Add a key frame set of values at the given key point. This will insert the values at the correct position within the array for the given key. If two keys have the same value, the new key is inserted before the old one.

Parameters:
key - The value of the key to use
pt - The point data to take information from

pointValue

public javax.vecmath.Point3f pointValue(float key)
Get the interpolated value of the point at the given key value. If the key lies outside the range of the values defined, it will be clamped to the end point value. For speed reasons, this will return a reusable point instance. Do not modify the values or keep a reference to this as it will change values between calls.

Parameters:
key - The key value to get the position for
Returns:
A point representation of the value at that position

floatValue

public float[] floatValue(float key)
Get the interpolated value of the point at the given key value. If the key lies outside the range of the values defined, it will be clamped to the end point value. For speed reasons, this will return a reusable float array. Do not modify the values or keep a reference to this as it will change values between calls.

Parameters:
key - The key value to get the position for
Returns:
An array of the values at that position [x, y, z]

toString

public java.lang.String toString()
Create a string representation of this interpolator's values

Overrides:
toString in class java.lang.Object
Returns:
A nicely formatted string representation

j3d.org Code

Latest Info from http://code.j3d.org/
Copyright © 2001 - j3d.org