

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object org.proteinshader.math.Hermite
public class Hermite
Calculates a cubic equation between two control points so that points
on the curve in between can be interpolated.
To use Hermite interpolation, the xyzcoordinate and tangent must be
known for both the start point and the end point. Three separate
cubic equations will be determined: one for the x dimension, one for
the y dimension, and one for the z dimension. The free variable in
each cubic equation is the parameter t. The parameter t is 0.0 for
the start point and 1.0 for the end point. Once the constants for the
cubic equations have been determined, a parameter t between 0.0 and
1.0 can be plugged in to get the xyzcoordinate and tangent of any
point on the curve between the start and end points.
The equations shown below are for calculating the y dimension, but the
exact same math applies to the x and z dimensions. These equations
can be found on pages 643645 of 'Computer Graphics Using OpenGL'
by F.S. Hill, 2nd Edition (2001).
Cubic equation for y: y(t) = Ay*t^3 + By*t^2 + Cy*t + Dy
First derivative for y: y(t) = 3Ay*t^2 + 2By*t + Cy
Input values for Hermite interpolation:
p1.y  the yvalue at the start point
p2.y  the yvalue at the end point
tan1.y  the yvalue of the tangent at the start point
tan2.y  the yvalue of the tangent at the end point
Solutions for the coefficients of the cubic equation:
Ay = tan2.y + tan1.y  2(p2.y  p1.y)
By = 3(p2.y  p1.y)  2tan1.y  tan2.y
Cy = tan1.y
Dy = p1.y
Constructor Summary  

Hermite(Point3d p1,
Point3d p2,
Vec3d tan1,
Vec3d tan2)
Constructs a Hermite object by using the input points and vectors to calculate and store the coefficients needed for the cubic equations for x(t), y(t), and z(t). 

Hermite(Vec3d p1,
Vec3d p2,
Vec3d tan1,
Vec3d tan2)
Constructs a Hermite object by using the input vectors to calculate and store the coefficients needed for the cubic equations for x(t), y(t), and z(t). 
Method Summary  

Point3d 
calculatePoint(double t)
Uses Hermite interpolation to calculate a point on the curve between the start and end points given the constructor. 
Vec3d 
calculateReverseTangent(double t)
Gets the tangent from the calculateTangent() method and reverses its direction. 
Vec3d 
calculateTangent(double t)
Uses Hermite interpolation to calculate the tangent of a point on the cubic equation between the start and end points given the constructor. 
Vec3d 
calculateTranslation(double t)
If the xyzpoint obtained by calculatePoint() is going to be used to translate an object from the origin to the point, then it is convenient for a vector to be returned instead of a point. 
Hermite 
clone()
Creates a clone of the calling Hermite object and returns it. 
Methods inherited from class java.lang.Object 

equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 
Constructor Detail 

public Hermite(Point3d p1, Point3d p2, Vec3d tan1, Vec3d tan2)
p1
 the start point of the cubic equation.p2
 the end point of the cubic equation.tan1
 the tangent vector for the start point.tan2
 the tangent vector for the end point.public Hermite(Vec3d p1, Vec3d p2, Vec3d tan1, Vec3d tan2)
p1
 the start point of the cubic equation (as a vector).p2
 the end point of the cubic equation (as a vector).tan1
 the tangent vector for the start point.tan2
 the tangent vector for the end point.Method Detail 

public Point3d calculatePoint(double t)
t
 a parameter from 0.0 to 1.0.
public Vec3d calculateTranslation(double t)
t
 a parameter from 0.0 to 1.0.
public Vec3d calculateTangent(double t)
t
 a parameter from 0.0 to 1.0.
public Vec3d calculateReverseTangent(double t)
t
 a parameter from 0.0 to 1.0.
public Hermite clone()
clone
in class Object


PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 