org.proteinshader.math
Class LocalFrame

java.lang.Object
  extended by org.proteinshader.math.LocalFrame

public class LocalFrame
extends Object

Stores a local coordinate frame as a rotation (a Quaternion) and a translation (a Point3d).

In order to render a region of secondary structure (a Helix, BetaStrand, or Loop), a waist polygon will be swept along a spline (a curved line formed by piecewise cubic equations). At each control point along the spline, a local coordinate frame (a rotation and an xyz-translation) will be used to correctly position the waist polygon.


Constructor Summary
LocalFrame()
          Constructs a LocalFrame with the identity quaternion, (0, 0, 0, 1) and a translation of (0, 0, 0).
LocalFrame(double qX, double qY, double qZ, double qW, double x, double y, double z)
          Constructs a LocalFrame using the rotation and translation given as arguments.
LocalFrame(Quaternion rotation, Vec3d translation)
          Constructs a LocalFrame that holds on to the Quaternion and Vec3d given as arguments.
LocalFrame(Vec3d N, Vec3d B, Vec3d T, double x, double y, double z)
          Constructs a LocalFrame equivalent to the rotation matrix [N B T] and the translation (x, y, z).
 
Method Summary
 LocalFrame clone()
          Returns a clone of the calling LocalFrame.
 void generateMatrix(Vec3d N, Vec3d B, Vec3d T)
          Generates a 3 x 3 rotation matrix (actually 3 column vectors) that is equivalent to the rotation quaternion.
 Vec3d getBinormal()
          Converts the rotation (a Quaternion) into a 3 x 3 rotation matrix and the returns the second column vector (the Binormal).
 Vec3d getNormal()
          Converts the rotation (a Quaternion) into a 3 x 3 rotation matrix and the returns the first column vector (the Normal).
 Vec3d getReverseTangent()
          Converts the rotation (a Quaternion) into a 3 x 3 rotation matrix and the returns the third column vector (the Tangent) after reversing its direction.
 Vec3d getTangent()
          Converts the rotation (a Quaternion) into a 3 x 3 rotation matrix and the returns the third column vector (the Tangent).
 Vec3d getTranslation()
          Returns a copy of the translation vector held by this LocalFrame.
 Point3d multiply(Point3d vertex)
          Multiplies the vertex by the local frame.
 Point3d rotate(Point3d point)
          Returns a new point produced by rotating the point given as an argument by the quaternion held in this local frame.
 Vec3d rotate(Vec3d vector)
          Returns a new vector produced by rotating the vector given as an argument by the quaternion held in this local frame.
 void setRotation(double x, double y, double z, double w)
          Set the rotation to the quaternion xyzw-values given as arguments.
 void setRotation(Quaternion rotation)
          Holds on to the Quaternion given as an argument so that it can be used as the rotation of the local coordinate frame.
 void setTranslation(double x, double y, double z)
          Set the translation to the xyz-values given as arguments.
 void setTranslation(Vec3d translation)
          Holds on the the vector given as an argument so that it can be used as the translation for the local coordinate frame.
 String toString()
          As a convenience for debugging, the toString() method returns the xyzw-components of the quaternion and the translation vector in the form "{ (x, y, z, w), (x, y, z) }".
 void translate(Point3d vertex)
          The vertex given as an argument is modified by adding to it the xyz-coordinates of the translation vector held by this LocalFrame.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LocalFrame

public LocalFrame()
Constructs a LocalFrame with the identity quaternion, (0, 0, 0, 1) and a translation of (0, 0, 0).


LocalFrame

public LocalFrame(Vec3d N,
                  Vec3d B,
                  Vec3d T,
                  double x,
                  double y,
                  double z)
Constructs a LocalFrame equivalent to the rotation matrix [N B T] and the translation (x, y, z).

The matrix [N B T] is used to create a Quaternion (and references to the vectors N, B, and T are not kept).

Parameters:
N - the normal (3rd column vector of a rotation matrix).
B - the binormal (2nd column vector of a rotation matrix).
T - the tangent (1st column vector of a rotation matrix).
x - the x-coordinate of a translation.
y - the y-coordinate of a translation.
z - the z-coordinate of a translation.

LocalFrame

public LocalFrame(Quaternion rotation,
                  Vec3d translation)
Constructs a LocalFrame that holds on to the Quaternion and Vec3d given as arguments.

If references to the Quaternion and Vec3d should not be kept, then the 7-argument constructor should be used.

Parameters:
rotation - the quaternion equivalent to a rotation matrix.
translation - an (x, y, z) translation.

LocalFrame

public LocalFrame(double qX,
                  double qY,
                  double qZ,
                  double qW,
                  double x,
                  double y,
                  double z)
Constructs a LocalFrame using the rotation and translation given as arguments.

Parameters:
qX - the x-value of the rotation quaternion.
qY - the y-value of the rotation quaternion.
qZ - the z-value of the rotation quaternion.
qW - the w-value of the rotation quaternion.
x - the x-coordinate of a translation.
y - the y-coordinate of a translation.
z - the z-coordinate of a translation.
Method Detail

clone

public LocalFrame clone()
Returns a clone of the calling LocalFrame.

The clone is a deep clone (completely independent of the original).

Overrides:
clone in class Object
Returns:
A new LocalFrame.

generateMatrix

public void generateMatrix(Vec3d N,
                           Vec3d B,
                           Vec3d T)
Generates a 3 x 3 rotation matrix (actually 3 column vectors) that is equivalent to the rotation quaternion.

Parameters:
N - a normal vector (N.x, N.y, N.z) to fill with values.
B - a binormal vector (B.x, B.y, B.z) to fill with values.
T - a tangent vector (T.x, T.y, T.z) to fill with values.

getNormal

public Vec3d getNormal()
Converts the rotation (a Quaternion) into a 3 x 3 rotation matrix and the returns the first column vector (the Normal).

Returns:
The Normal vector (N.x, N.y, N.z).

getBinormal

public Vec3d getBinormal()
Converts the rotation (a Quaternion) into a 3 x 3 rotation matrix and the returns the second column vector (the Binormal).

Returns:
The Binormal vector (B.x, B.y, Z.z).

getTangent

public Vec3d getTangent()
Converts the rotation (a Quaternion) into a 3 x 3 rotation matrix and the returns the third column vector (the Tangent).

Returns:
The Tangent vector (T.x, T.y, T.z).

getReverseTangent

public Vec3d getReverseTangent()
Converts the rotation (a Quaternion) into a 3 x 3 rotation matrix and the returns the third column vector (the Tangent) after reversing its direction.

Returns:
The reverse Tangent vector (T.x, T.y, T.z).

getTranslation

public Vec3d getTranslation()
Returns a copy of the translation vector held by this LocalFrame.

Returns:
The translation vector.

multiply

public Point3d multiply(Point3d vertex)
Multiplies the vertex by the local frame.

The vertex given as an argument is first multiplied by the rotation quaternion (equivalent to a 3 x 3 rotation matrix in OpenGL) and then translated by adding the translation vector to it.

Parameters:
vertex - a vertex of a waist polygon.
Returns:
A new vertex.

rotate

public Point3d rotate(Point3d point)
Returns a new point produced by rotating the point given as an argument by the quaternion held in this local frame.

The point given as an argument is not modified.

Parameters:
point - the point to rotate
Returns:
A new point.

rotate

public Vec3d rotate(Vec3d vector)
Returns a new vector produced by rotating the vector given as an argument by the quaternion held in this local frame.

The vector given as an argument is not modified.

Parameters:
vector - the vector to rotate.
Returns:
A new vector.

translate

public void translate(Point3d vertex)
The vertex given as an argument is modified by adding to it the xyz-coordinates of the translation vector held by this LocalFrame.

Parameters:
vertex - the vertex of a waist polygon.

setRotation

public void setRotation(double x,
                        double y,
                        double z,
                        double w)
Set the rotation to the quaternion xyzw-values given as arguments.

Parameters:
x - the x-coordinate for the quaternion.
y - the y-coordinate for the quaternion.
z - the z-coordinate for the quaternion.
w - the w-coordinate for the quaternion.

setRotation

public void setRotation(Quaternion rotation)
Holds on to the Quaternion given as an argument so that it can be used as the rotation of the local coordinate frame.

This method does not copy the Quaternion: it keeps a reference to the Quaternion. If the Quaternion should not be held on to by the LocalFrame, then the setRotation( x, y, z, w ) method should be used instead.

Parameters:
rotation - a rotation in the form of a Quaternion.

setTranslation

public void setTranslation(double x,
                           double y,
                           double z)
Set the translation to the xyz-values given as arguments.

Parameters:
x - the x-coordinate for the translation.
y - the y-coordinate for the translation.
z - the z-coordinate for the translation.

setTranslation

public void setTranslation(Vec3d translation)
Holds on the the vector given as an argument so that it can be used as the translation for the local coordinate frame.

This method does not copy the vector: it keeps a reference to the vector. If the vector should not be held on to by the LocalFrame, then the setTranslation( x, y, z ) method should be used instead.

Parameters:
translation - the translation vector.

toString

public String toString()
As a convenience for debugging, the toString() method returns the xyzw-components of the quaternion and the translation vector in the form "{ (x, y, z, w), (x, y, z) }".

Overrides:
toString in class Object
Returns:
A String representation of this LocalFrame.


Copyright © 2007-2008