CubeTwister 2.0alpha142 2012-02-11

ch.randelshofer.geom3d
Class DefaultTransform3DModel

java.lang.Object
  extended by ch.randelshofer.beans.AbstractStateModel
      extended by ch.randelshofer.geom3d.DefaultTransform3DModel
All Implemented Interfaces:
Transform3DModel

public class DefaultTransform3DModel
extends AbstractStateModel
implements Transform3DModel

The default implementation of the Transform3DModel interface. This is a Transform3D object that fires change events, when its matrix changes.

Author:
Werner Randelshofer

Field Summary
 
Fields inherited from class ch.randelshofer.beans.AbstractStateModel
changeEvent, listenerList
 
Constructor Summary
DefaultTransform3DModel()
          Creates a new instance.
DefaultTransform3DModel(double[][] matrix)
          Constructs a new transform from 12 double precision values representing the 12 specifiable entries of the 4x4 transformation matrix.
DefaultTransform3DModel(double m00, double m10, double m20, double m30, double m01, double m11, double m21, double m31, double m02, double m12, double m22, double m32)
          Constructs a new transform from 12 double precision values representing the 12 specifiable entries of the 4x4 transformation matrix.
 
Method Summary
 void concatenate(Transform3D t)
          Concatenates a transform Tx to this transform Cx.
 Transform3D getTransform()
          Returns the current state of the model.
 Transform3D getTransform(Transform3D t)
          Copies the current state of the model into the given Transform3D object and returns it.
 void rotate(double rx, double ry, double rz)
          Concatenates this transform with a rotation transformation.
 void rotateX(double rx)
          Concatenates this transform with a rotation transformation.
 void rotateY(double ry)
          Concatenates this transform with a rotation transformation.
 void rotateZ(double rz)
          Concatenates this transform with a rotation transformation.
 void scale(double sx, double sy, double sz)
          Concatenates this transform with a scaling transformation.
 void setToIdentity()
          Resets this transform to the Identity transform.
 void setTransform(Transform3D t)
          Sets this transform to a copy of the transform in the specified Transform3D object.
 void translate(double tx, double ty, double tz)
          Concatenates this transform with a translation transformation.
 
Methods inherited from class ch.randelshofer.beans.AbstractStateModel
addChangeListener, fireStateChanged, removeChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ch.randelshofer.geom3d.Transform3DModel
addChangeListener, removeChangeListener
 

Constructor Detail

DefaultTransform3DModel

public DefaultTransform3DModel()
Creates a new instance.


DefaultTransform3DModel

public DefaultTransform3DModel(double m00,
                               double m10,
                               double m20,
                               double m30,
                               double m01,
                               double m11,
                               double m21,
                               double m31,
                               double m02,
                               double m12,
                               double m22,
                               double m32)
Constructs a new transform from 12 double precision values representing the 12 specifiable entries of the 4x4 transformation matrix.


DefaultTransform3DModel

public DefaultTransform3DModel(double[][] matrix)
Constructs a new transform from 12 double precision values representing the 12 specifiable entries of the 4x4 transformation matrix.

Method Detail

setToIdentity

public void setToIdentity()
Resets this transform to the Identity transform.

Specified by:
setToIdentity in interface Transform3DModel

rotateX

public void rotateX(double rx)
Concatenates this transform with a rotation transformation. This is equivalent to calling concatenate(R), where R is an Transform3D represented by the following matrix:
    [ 1   0         0        0 ]
    [ 0   cos(rx)    sin(rx)   0 ]
    [ 0   -sin(rx)   cos(rx)   0 ]
      [ 0   0         0        1 ]
 
Positive values rotate counterclockwise.

Specified by:
rotateX in interface Transform3DModel
Parameters:
rx - Rotation along the x axis in radians.

rotateY

public void rotateY(double ry)
Concatenates this transform with a rotation transformation. This is equivalent to calling concatenate(R), where R is an Transform3D represented by the following matrix:
    [ cos(ry)   0   -sin(ry)   0 ]
    [ 0        1   0         0 ]
    [ sin(ry)   0   cos(ry)    0 ]
      [ 0        0   0         1 ]
 
Positive values rotate counterclockwise.

Specified by:
rotateY in interface Transform3DModel
Parameters:
ry - Rotation along the y axis in radians.

rotateZ

public void rotateZ(double rz)
Concatenates this transform with a rotation transformation. This is equivalent to calling concatenate(R), where R is an Transform3D represented by the following matrix:
    [ cos(rz)    sin(rz)   0   0 ]
    [ -sin(rz)   cos(rz)   0   0 ]
    [ 0         0        1   0 ]
      [ 0         0        0   1 ]
 
Positive values rotate counterclockwise.

Specified by:
rotateZ in interface Transform3DModel
Parameters:
rz - Rotation along the z axis in radians.

scale

public void scale(double sx,
                  double sy,
                  double sz)
Concatenates this transform with a scaling transformation. This is equivalent to calling concatenate(S), where S is an Transform3D represented by the following matrix:
    [   sx   0    0    0   ]
    [   0    sy   0    0   ]
    [   0    0    sz   0   ]
    [   0    0    0    1   ]
 

Specified by:
scale in interface Transform3DModel

translate

public void translate(double tx,
                      double ty,
                      double tz)
Concatenates this transform with a translation transformation. This is equivalent to calling concatenate(T), where T is an Transform3D represented by the following matrix:
    [   1    0    0    tx  ]
    [   0    1    0    ty  ]
    [   0    0    1    tz  ]
    [   0    0    0    1   ]
 

Specified by:
translate in interface Transform3DModel

concatenate

public void concatenate(Transform3D t)
Concatenates a transform Tx to this transform Cx. Cx is updated to perform the combined transformation. Transforming a point p by the updated transform Cx' is equivalent to first transforming p by Tx and then transforming the result by the original transform Cx. In other words, Cx'(p) = Cx(Tx(p)). In matrix notation, if this transform Cx is represented by the matrix [this] and Tx is represented by the matrix [Tx], then this method does the following:
    [this] = [this] x [Tx]
 

Specified by:
concatenate in interface Transform3DModel
Parameters:
t - The transform object to be concatenated with this transform object.

setTransform

public void setTransform(Transform3D t)
Sets this transform to a copy of the transform in the specified Transform3D object.

Specified by:
setTransform in interface Transform3DModel
Parameters:
t - the Transform3D object from which to copy the transform

getTransform

public Transform3D getTransform()
Returns the current state of the model.

Specified by:
getTransform in interface Transform3DModel

getTransform

public Transform3D getTransform(Transform3D t)
Copies the current state of the model into the given Transform3D object and returns it.

Specified by:
getTransform in interface Transform3DModel

rotate

public void rotate(double rx,
                   double ry,
                   double rz)
Concatenates this transform with a rotation transformation. This is equivalent to calling concatenate0(R), where R is an Transform3D represented by the following matrix:
   [ cos(rz)*cos(ry)     cos(rz)*sin(ry)*sin(rx)     cos(rz)*-sin(ry)*cos(rx)    0 ]
                           +sin(rz)*cos(rx)            +sin(rz)*-sin(ry)*cos(rx)

   [ -sin(rz)*cos(ry)    -sin(rz)*sin(ry)*sin(rx)    -sin(rz)*-sin(ry)*cos(rx)   0 ]
                           +cos(rz)*cos(rx)            +cos(rz)*sin(rx)

   [ sin(ry)             cos(ry)*-sin(rx)            cos(ry)*cos(rx)            0 ]

     [ 0                   0                           0                        1 ]
 
Positive values rotate counterclockwise.

Specified by:
rotate in interface Transform3DModel
Parameters:
rx - Rotation along the x axis in radians.
ry - Rotation along the y axis in radians.
rz - Rotation along the z axis in radians.

(c) Werner Randelshofer.
All rights reserved.