com.bramosystems.oss.player.core.client.geom
Class TransformationMatrix

java.lang.Object
  extended by com.bramosystems.oss.player.core.client.geom.TransformationMatrix

public class TransformationMatrix
extends java.lang.Object

Represents a transformation matrix that determines how to map points from one coordinate space to another. The matrix can be used to perform various two-dimensional graphical transformations including translation (x and y repositioning), rotation, scaling, and skewing.

A transformation matrix object is a 3x3 matrix with the following contents:

      [ a   b   u ]
      [ c   d   v ]
      [ tx  ty  w ]
 
Note: Property values u and v are always 0.0, while w is always 1.0.

Note:The 3x3 matrix is implemented with a Matrix2D object.

Since:
1.1
Author:
Sikirulai Braheem
See Also:
Matrix2D

Constructor Summary
TransformationMatrix()
          Constructs a new identity TransformationMatrix
TransformationMatrix(Matrix2D matrix)
          Constructs a TransformationMatrix using the specified matrix.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 Matrix2D getMatrix()
          Returns the backing 3x3 matrix
 int hashCode()
           
 void invert()
          Performs an inversion on this matrix
 void multiply(TransformationMatrix m)
          Performs matrix multiplication on this matrix with the specified transformation matrix and keeps the result in this matrix
 void rotate(double angle)
          Applies a rotation transformation to this matrix.
 void scale(double x, double y)
          Performs a scalling transformation on this matrix along the x and y axes.
 void skew(double ax, double ay)
          Applies a skewing transformation to this matrix
 void toIdentity()
          Converts this matrix to an identity matrix
 java.lang.String toString()
          Returns the matrix elements as a String
 void translate(double x, double y)
          Performs a displacement transformation on this matrix along the x and y axes
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TransformationMatrix

public TransformationMatrix()
Constructs a new identity TransformationMatrix


TransformationMatrix

public TransformationMatrix(Matrix2D matrix)
Constructs a TransformationMatrix using the specified matrix.

Parameters:
matrix - the matrix
Method Detail

getMatrix

public Matrix2D getMatrix()
Returns the backing 3x3 matrix

Returns:
the backing 3x3 matrix

translate

public void translate(double x,
                      double y)
Performs a displacement transformation on this matrix along the x and y axes

Parameters:
x - displacement along the x-axis (in pixels)
y - displacement along the y-axis (in pixels)

scale

public void scale(double x,
                  double y)
Performs a scalling transformation on this matrix along the x and y axes. The x-axis is multiplied by x and the y-axis is multiplied by y.

Parameters:
x - multiplier used to scale the matrix along the x-axis
y - multiplier used to scale the matrix along the y-axis

rotate

public void rotate(double angle)
Applies a rotation transformation to this matrix.

Parameters:
angle - angle of rotation in radians

skew

public void skew(double ax,
                 double ay)
Applies a skewing transformation to this matrix

Parameters:
ax - skew angle along the x-axis (in radians)
ay - skew angle along the y-axis (in radians)

multiply

public void multiply(TransformationMatrix m)
Performs matrix multiplication on this matrix with the specified transformation matrix and keeps the result in this matrix

Parameters:
m - the matrix to multipy with this matrix

invert

public void invert()
Performs an inversion on this matrix


toIdentity

public void toIdentity()
Converts this matrix to an identity matrix


toString

public java.lang.String toString()
Returns the matrix elements as a String

Overrides:
toString in class java.lang.Object
Returns:
the matrix in the form a, b, u, c, d, v, tx, ty, w

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object


Copyright © 2009-2011. All Rights Reserved.