Class Transform2D

java.lang.Object
  extended by Transform2D

public class Transform2D
extends java.lang.Object

Transform2D wraps a Matrix2D object and provides,

Author:
C. D'Arcy

Nested Class Summary
static class Transform2D.Type
          ZERO can be used to construct a Transform2D object defining the zero matrix.
 
Constructor Summary
Transform2D()
          Constructs a Transform2D object encapsulating the ZERO matrix.
Transform2D(Matrix2D matrix2D)
          Constructs a Transform2D object by duplicating the elements of the Matrix2D parameter
Transform2D(Transform2D.Type kind)
          Constructs a Transform2D object encapsulating either, ZERO - a Matrix2D whose elements are all 0s IDENTITY - a Matrix2D object consisting of 1s on the principal diagonal and 0s elsewhere
Transform2D(Transform2D transform2D)
          Constructs a Transform2D object by duplicating the elements of the Matrix2D object encapsulated by the Transform2D parameter
 
Method Summary
 Transform2D add(Transform2D other)
          Returns the sum of the matrix elements of this Transform2D object (augend) and the parameter (addend) by calling Matrix2D's add method.
 Matrix2D getTransform2D()
          Accessor method that return the elements of matrix transform
 Transform2D mul(Transform2D other)
          Returns the product of the matrix elements of this Transform2D object (multiplicand) and the parameter (multiplier) by calling Matrix2D's mul method.
 void setRotation(double a)
          Modifier method that sets the matrix transform required to rotate the preimage around the origin: cos a -sin a 0 / sin a cos a 0 / 0 0 1
 void setScale(double s)
          Modifier method that sets the matrix transform to s 0 0 / 0 s 0 / 0 0 1
 void setTransform2D(Matrix2D matrix2D)
          Modifier method that sets the elements of matrix transform to the elements of the matrix parameter.
 void setTranslation(Point2D p)
          Modifier method that sets the matrix transform to 1 0 p.x / 0 1 p.y / 0 0 1
 Transform2D sub(Transform2D other)
          Returns the difference of the matrix elements of this Transform2D object (minuend) and the parameter (subtrahend) by calling Matrix2D's sub method.
 java.lang.String toString()
          Relays a call to Matrix2D.toString() back to the client
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Transform2D

public Transform2D()
Constructs a Transform2D object encapsulating the ZERO matrix.


Transform2D

public Transform2D(Transform2D.Type kind)
Constructs a Transform2D object encapsulating either,
  1. ZERO - a Matrix2D whose elements are all 0s
  2. IDENTITY - a Matrix2D object consisting of 1s on the principal diagonal and 0s elsewhere


Transform2D

public Transform2D(Matrix2D matrix2D)
Constructs a Transform2D object by duplicating the elements of the Matrix2D parameter


Transform2D

public Transform2D(Transform2D transform2D)
Constructs a Transform2D object by duplicating the elements of the Matrix2D object encapsulated by the Transform2D parameter

Method Detail

setTransform2D

public void setTransform2D(Matrix2D matrix2D)
Modifier method that sets the elements of matrix transform to the elements of the matrix parameter.

Parameters:
matrix2D - the matrix containing the new elements of the transform

getTransform2D

public Matrix2D getTransform2D()
Accessor method that return the elements of matrix transform


setTranslation

public void setTranslation(Point2D p)
Modifier method that sets the matrix transform to 1 0 p.x / 0 1 p.y / 0 0 1

Parameters:
p - the (p.x,p.y) translation

setScale

public void setScale(double s)
Modifier method that sets the matrix transform to s 0 0 / 0 s 0 / 0 0 1

Parameters:
s - the scale factor

setRotation

public void setRotation(double a)
Modifier method that sets the matrix transform required to rotate the preimage around the origin: cos a -sin a 0 / sin a cos a 0 / 0 0 1

Parameters:
a - the angle of rotation

add

public Transform2D add(Transform2D other)
Returns the sum of the matrix elements of this Transform2D object (augend) and the parameter (addend) by calling Matrix2D's add method.

Parameters:
other - the addend

sub

public Transform2D sub(Transform2D other)
Returns the difference of the matrix elements of this Transform2D object (minuend) and the parameter (subtrahend) by calling Matrix2D's sub method.

Parameters:
other - the subtrahend

mul

public Transform2D mul(Transform2D other)
Returns the product of the matrix elements of this Transform2D object (multiplicand) and the parameter (multiplier) by calling Matrix2D's mul method.

Parameters:
other - the multiplier

toString

public java.lang.String toString()
Relays a call to Matrix2D.toString() back to the client

Overrides:
toString in class java.lang.Object