com.sun.j3d.utils.behaviors.interpolators
Class KBCubicSplineSegment

java.lang.Object
  extended by com.sun.j3d.utils.behaviors.interpolators.KBCubicSplineSegment

public class KBCubicSplineSegment
extends java.lang.Object

The KBCubicSplineSegment class creates the representation of a Kochanek-Bartel's (also known as the TCB or Tension-Continuity-Bias Spline. This class takes 4 key frames as its input (using KBKeyFrame). If interpolating between the ith and (i+1)th key frame then the four key frames that need to be specified are the (i-1)th, ith, (i+1)th and (i+2)th keyframes in order. The KBCubicSegmentClass then pre-computes the hermite interpolation basis coefficients if the (i+1)th frame has the linear flag set to zero. These are used to calculate the interpolated position, scale and quaternions when they requested by the user using the getInterpolated* methods. If the the (i+1)th frame's linear flag is set to 1 then the class uses linear interpolation to calculate the interpolated position, scale, heading pitch and bank it returns through the getInterpolated* methods.

Since:
Java3D 1.2

Field Summary
(package private)  float b0
           
(package private)  float b1
           
(package private)  float b2
           
(package private)  float b3
           
(package private)  Point3f c0
           
(package private)  Point3f c1
           
(package private)  Point3f c2
           
(package private)  Point3f c3
           
(package private)  float dda
           
(package private)  float ddb
           
(package private)  float dsa
           
(package private)  float dsb
           
(package private)  Point3f e0
           
(package private)  Point3f e1
           
(package private)  Point3f e2
           
(package private)  Point3f e3
           
(package private)  float h0
           
(package private)  float h1
           
(package private)  float h2
           
(package private)  float h3
           
(package private)  KBKeyFrame[] keyFrame
           
(package private)  float length
           
(package private)  int linear
           
(package private) static double[] modCoeff
           
(package private) static double[] modRoot
           
(package private)  float one_minus_b_in
           
(package private)  float one_minus_b_out
           
(package private)  float one_minus_c_in
           
(package private)  float one_minus_c_out
           
(package private)  float one_minus_t_in
           
(package private)  float one_minus_t_out
           
(package private)  float one_plus_b_in
           
(package private)  float one_plus_b_out
           
(package private)  float one_plus_c_in
           
(package private)  float one_plus_c_out
           
(package private)  float p0
           
(package private)  float p1
           
(package private)  float p2
           
(package private)  float p3
           
 
Constructor Summary
KBCubicSplineSegment()
           
KBCubicSplineSegment(KBKeyFrame kf0, KBKeyFrame kf1, KBKeyFrame kf2, KBKeyFrame kf3)
          Creates a cubic spline segment between two key frames using the key frames provided.
 
Method Summary
private  void computeCommonCoefficients(KBKeyFrame kf0, KBKeyFrame kf1, KBKeyFrame kf2, KBKeyFrame kf3)
           
private  void computeHermiteCoefficients(KBKeyFrame kf0, KBKeyFrame kf1, KBKeyFrame kf2, KBKeyFrame kf3)
           
 float computeLength(float u)
          Computes the length of the curve at a given point between key frames.
private  float computeSpeed(float u)
           
 float getInterpolatedBank(float u)
          Computes the interpolated bank along the curve at a given point between key frames and returns the interpolated value as a float This routine uses linear interpolation if the (i+1)th key frame's linear value is equal to 1.
 float getInterpolatedHeading(float u)
          Computes the interpolated heading along the curve at a given point between key frames and returns the interpolated value as a float This routine uses linear interpolation if the (i+1)th key frame's linear value is equal to 1.
 float getInterpolatedPitch(float u)
          Computes the interpolated pitch along the curve at a given point between key frames and returns the interpolated value as a float This routine uses linear interpolation if the (i+1)th key frame's linear value is equal to 1.
 void getInterpolatedPosition(float u, Point3f newPos)
          Computes the interpolated position along the curve at a given point between key frames and returns a Point3f with the interpolated x, y, and z scale components.
 void getInterpolatedPositionVector(float u, Vector3f newPos)
          Computes the interpolated position along the curve at a given point between key frames and returns a Vector3f with the interpolated x, y, and z scale components.
 void getInterpolatedScale(float u, Point3f newScale)
          Computes the interpolated scale along the curve at a given point between key frames and returns a Point3f with the interpolated x, y, and z scale components.
 float getInterpolatedValue(float u)
          Computes the ratio of the length of the spline from the ith key frame to the position specified by u to the length of the entire spline segment from the ith key frame to the (i+1) th key frame.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

modRoot

static final double[] modRoot

modCoeff

static final double[] modCoeff

keyFrame

KBKeyFrame[] keyFrame

c0

Point3f c0

c1

Point3f c1

c2

Point3f c2

c3

Point3f c3

e0

Point3f e0

e1

Point3f e1

e2

Point3f e2

e3

Point3f e3

h0

float h0

h1

float h1

h2

float h2

h3

float h3

p0

float p0

p1

float p1

p2

float p2

p3

float p3

b0

float b0

b1

float b1

b2

float b2

b3

float b3

one_minus_t_in

float one_minus_t_in

one_minus_c_in

float one_minus_c_in

one_minus_b_in

float one_minus_b_in

one_plus_c_in

float one_plus_c_in

one_plus_b_in

float one_plus_b_in

ddb

float ddb

dda

float dda

one_minus_t_out

float one_minus_t_out

one_minus_c_out

float one_minus_c_out

one_minus_b_out

float one_minus_b_out

one_plus_c_out

float one_plus_c_out

one_plus_b_out

float one_plus_b_out

dsb

float dsb

dsa

float dsa

length

float length

linear

int linear
Constructor Detail

KBCubicSplineSegment

KBCubicSplineSegment()

KBCubicSplineSegment

KBCubicSplineSegment(KBKeyFrame kf0,
                     KBKeyFrame kf1,
                     KBKeyFrame kf2,
                     KBKeyFrame kf3)
Creates a cubic spline segment between two key frames using the key frames provided. If creating a spline between the ith frame and the (i+1)th frame then send down the (i - 1)th, ith , (i+1)th and the (i+2)th key frames.

Parameters:
kf0 - (i - 1)th Key Frame
kf1 - ith Key Frame
kf2 - (i + 1)th Key Frame
kf3 - (i + 2)th Key Frame
Method Detail

computeCommonCoefficients

private void computeCommonCoefficients(KBKeyFrame kf0,
                                       KBKeyFrame kf1,
                                       KBKeyFrame kf2,
                                       KBKeyFrame kf3)

computeHermiteCoefficients

private void computeHermiteCoefficients(KBKeyFrame kf0,
                                        KBKeyFrame kf1,
                                        KBKeyFrame kf2,
                                        KBKeyFrame kf3)

computeLength

public float computeLength(float u)
Computes the length of the curve at a given point between key frames.

Parameters:
u - specifies the point between keyframes where 0 <= u <= 1.

computeSpeed

private float computeSpeed(float u)

getInterpolatedScale

public void getInterpolatedScale(float u,
                                 Point3f newScale)
Computes the interpolated scale along the curve at a given point between key frames and returns a Point3f with the interpolated x, y, and z scale components. This routine uses linear interpolation if the (i+1)th key frame's linear value is equal to 1.

Parameters:
u - specifies the point between keyframes where 0 <= u <= 1.
newScale - returns the interpolated x,y,z scale value in a Point3f

getInterpolatedPosition

public void getInterpolatedPosition(float u,
                                    Point3f newPos)
Computes the interpolated position along the curve at a given point between key frames and returns a Point3f with the interpolated x, y, and z scale components. This routine uses linear interpolation if the (i+1)th key frame's linear value is equal to 1.

Parameters:
u - specifies the point between keyframes where 0 <= u <= 1.
newPos - returns the interpolated x,y,z position in a Point3f

getInterpolatedPositionVector

public void getInterpolatedPositionVector(float u,
                                          Vector3f newPos)
Computes the interpolated position along the curve at a given point between key frames and returns a Vector3f with the interpolated x, y, and z scale components. This routine uses linear interpolation if the (i+1)th key frame's linear value is equal to 1.

Parameters:
u - specifies the point between keyframes where 0 <= u <= 1.
newPos - returns the interpolated x,y,z position in a Vector3f.

getInterpolatedHeading

public float getInterpolatedHeading(float u)
Computes the interpolated heading along the curve at a given point between key frames and returns the interpolated value as a float This routine uses linear interpolation if the (i+1)th key frame's linear value is equal to 1.

Parameters:
u - specifies the point between keyframes where 0 <= u <= 1.
Returns:
returns the interpolated heading value

getInterpolatedPitch

public float getInterpolatedPitch(float u)
Computes the interpolated pitch along the curve at a given point between key frames and returns the interpolated value as a float This routine uses linear interpolation if the (i+1)th key frame's linear value is equal to 1.

Parameters:
u - specifies the point between keyframes where 0 <= u <= 1.
Returns:
returns the interpolated pitch value

getInterpolatedBank

public float getInterpolatedBank(float u)
Computes the interpolated bank along the curve at a given point between key frames and returns the interpolated value as a float This routine uses linear interpolation if the (i+1)th key frame's linear value is equal to 1.

Parameters:
u - specifies the point between keyframes where 0 <= u <= 1.
Returns:
returns the interpolated bank value

getInterpolatedValue

public float getInterpolatedValue(float u)
Computes the ratio of the length of the spline from the ith key frame to the position specified by u to the length of the entire spline segment from the ith key frame to the (i+1) th key frame. When the (i+1)th key frame's linear value is equal to 1, this is meaninful otherwise it should return u.

Parameters:
u - specifies the point between keyframes where 0 <= u <= 1.
Returns:
the interpolated ratio


Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms.