com.xinapse.geom3d
Class AffineTransform3D

java.lang.Object
  extended by javax.media.j3d.Transform3D
      extended by com.xinapse.geom3d.AffineTransform3D
All Implemented Interfaces:
java.lang.Cloneable

public class AffineTransform3D
extends javax.media.j3d.Transform3D
implements java.lang.Cloneable

The AffineTransform3D class represents a 3D affine transform that performs a linear mapping from 3D coordinates to other 3D coordinates that preserves the "straightness" and "parallelness" of lines. Affine transformations can be constructed using sequences of translations, scales, flips, rotations, and shears.

Such a coordinate transformation can be represented by a 4 row by 4 column matrix with an implied last row of [ 0 0 0 1 ]. This matrix transforms source coordinates (x, y, z) into destination coordinates (x', y', z') by considering them to be a column vector and multiplying the coordinate vector by the matrix according to the following process:

   [ x']   [  m00  m01  m02  m03  ] [ x ]   [ m00x + m01y + m02z + m03 ]
   [ y'] = [  m10  m11  m12  m13  ] [ y ] = [ m10x + m11y + m12z + m13 ]
   [ z'] = [  m20  m21  m22  m23  ] [ z ]   [ m20x + m21y + m22z + m23 ]
   [ 1 ]   [   0    0    0    1   ] [ 1 ]   [             1            ]
   


Field Summary
 
Fields inherited from class javax.media.j3d.Transform3D
AFFINE, CONGRUENT, IDENTITY, NEGATIVE_DETERMINANT, ORTHOGONAL, RIGID, SCALE, TRANSLATION, ZERO
 
Constructor Summary
AffineTransform3D()
          Constructs and initializes a transform to the identity matrix.
AffineTransform3D(float[] matrix)
          Constructs and initializes a transform from the float array of length 12; the top row of the matrix is initialized to the first four elements of the array, and so on.
 
Method Summary
 java.lang.Object clone()
          Creates and returns a copy of this AffineTransform3D.
 void get12(float[] matrix)
          Sets the matrix values of this transform to the matrix values in the single precision array parameter.
static void main(java.lang.String[] args)
          Runs the self-test for AffineTransform3D.
 void set12(float[] matrix)
          Sets the matrix values of this transform to the matrix values in the single precision array parameter.
 java.lang.String toPrintString()
          Returns a java.lang.String suitable for printing out this AffineTransform3D in a form suitable for later parsing.
 java.lang.String toString()
          Returns a String that represents the value of this Object.
 void transform(float[] ptSrc, float[] ptDst)
          Transforms an array of (x,y,z) locations by this transform.
 float[] transform(int nX, int nY, int nZ, float pixelXSize, float pixelYSize, float pixelZSize, float[] dst)
          Transforms a set of points by this transform.
 void transform(javax.vecmath.Point3f[] ptSrc, int srcOff, javax.vecmath.Point3f[] ptDst, int dstOff, int numPts)
          Transforms an array of point objects by this transform.
 
Methods inherited from class javax.media.j3d.Transform3D
add, add, determinant, epsilonEquals, equals, equals, frustum, get, get, get, get, get, get, get, get, get, get, get, get, get, get, get, get, getAutoNormalize, getBestType, getDeterminantSign, getRotationScale, getRotationScale, getScale, getScale, getType, hashCode, invert, invert, lookAt, mul, mul, mul, mul, mulInverse, mulInverse, mulTransposeBoth, mulTransposeLeft, mulTransposeRight, normalize, normalize, normalizeCP, normalizeCP, ortho, perspective, rotX, rotY, rotZ, scaleAdd, scaleAdd, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, set, setAutoNormalize, setEuler, setIdentity, setNonUniformScale, setRotation, setRotation, setRotation, setRotation, setRotation, setRotation, setRotationScale, setRotationScale, setScale, setScale, setTranslation, setTranslation, setZero, sub, sub, transform, transform, transform, transform, transform, transform, transform, transform, transform, transform, transform, transform, transpose, transpose
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AffineTransform3D

public AffineTransform3D()
Constructs and initializes a transform to the identity matrix.


AffineTransform3D

public AffineTransform3D(float[] matrix)
Constructs and initializes a transform from the float array of length 12; the top row of the matrix is initialized to the first four elements of the array, and so on. The type of the transform object is classified internally.

Parameters:
matrix - a float array of 12.
Method Detail

get12

public void get12(float[] matrix)
Sets the matrix values of this transform to the matrix values in the single precision array parameter. The matrix type is classified internally by the AffineTransform3D class.

Parameters:
matrix - the single precision array of length 12 in row major format.

set12

public void set12(float[] matrix)
Sets the matrix values of this transform to the matrix values in the single precision array parameter. The matrix type is classified internally by the AffineTransform3D class.

Parameters:
matrix - the single precision array of length 12 in row major format.

transform

public void transform(javax.vecmath.Point3f[] ptSrc,
                      int srcOff,
                      javax.vecmath.Point3f[] ptDst,
                      int dstOff,
                      int numPts)
Transforms an array of point objects by this transform. If any element of the ptDst array is null, a new Point3f object is allocated and stored into that element before storing the results of the transformation.

Note that this method does not take any precautions to avoid problems caused by storing results into Point3f objects that will be used as the source for calculations further down the source array. This method does guarantee that if a specified Point3f object is both the source and destination for the same single point transform operation then the results will not be stored until the calculations are complete to avoid storing the results on top of the operands. If, however, the destination Point3f object for one operation is the same object as the source Point3f object for another operation further down the source array then the original coordinates in that point are overwritten before they can be converted.

Parameters:
ptSrc - the array containing the source point objects
ptDst - the array into which the transform point objects are returned.
srcOff - the offset to the first point object to be transformed in the source array.
dstOff - the offset to the location of the first transformed point object that is stored in the destination array.
numPts - the number of point objects to be transformed.

transform

public void transform(float[] ptSrc,
                      float[] ptDst)
Transforms an array of (x,y,z) locations by this transform.

Note that this method does not take any precautions to avoid problems caused by storing results that will be used as the source for calculations further down the source array. This method does guarantee that if a specified array is is both the source and destination for the same single point transform operation then the results will not be stored until the calculations are complete to avoid storing the results on top of the operands. If, however, the destination for one operation is the same object as the source for another operation further down the source array then the original coordinates in that point are overwritten before they can be converted.

Parameters:
ptSrc - the array containing the points in order x,y,z for point 1; x,y,z for point 2 etc.
ptDst - the array into which the transformed points are returned.

transform

public float[] transform(int nX,
                         int nY,
                         int nZ,
                         float pixelXSize,
                         float pixelYSize,
                         float pixelZSize,
                         float[] dst)
Transforms a set of points by this transform.

Parameters:
dst - an array large enough to hold the x, y and z coordinates of the transformed points (i.e., nX * nY * nZ * 3). If dst is null, a new array is created.

toString

public java.lang.String toString()
Returns a String that represents the value of this Object.

Overrides:
toString in class javax.media.j3d.Transform3D
Returns:
a String representing the value of this AffineTransform3D.

toPrintString

public java.lang.String toPrintString()
Returns a java.lang.String suitable for printing out this AffineTransform3D in a form suitable for later parsing.

Returns:
a java.lang.String detailing this AffineTransform3D in a form suitable for later parsing.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Creates and returns a copy of this AffineTransform3D.

Overrides:
clone in class java.lang.Object
Returns:
a a copy of this AffineTransform3D.
Throws:
java.lang.CloneNotSupportedException

main

public static void main(java.lang.String[] args)
Runs the self-test for AffineTransform3D.



Copyright 2006-2008 Xinapse Systems Limited. All Rights Reserved.