org.newdawn.slick.geom
Class Transform

java.lang.Object
  extended by org.newdawn.slick.geom.Transform

public class Transform
extends java.lang.Object

A 2 dimensional transformation that can be applied to Shape implemenations.

Author:
Mark

Constructor Summary
Transform()
          Create and identity transform
Transform(float[] matrixPosition)
          Create a transform for the given positions
Transform(float point00, float point01, float point02, float point10, float point11, float point12)
          Create a transform for the given positions
Transform(Transform other)
          Copy a transform
Transform(Transform t1, Transform t2)
          Concatanate to transform into one
 
Method Summary
 Transform concatenate(Transform tx)
          Update this Transform by concatenating the given Transform to this one.
static Transform createRotateTransform(float angle)
          Create a new rotation Transform
static Transform createRotateTransform(float angle, float x, float y)
          Create a new rotation Transform around the specified point
static Transform createScaleTransform(float xScale, float yScale)
          Create an new scaling Transform
static Transform createTranslateTransform(float xOffset, float yOffset)
          Create a new translation Transform
 float[] getMatrixPosition()
          Get an array representing this Transform.
 java.lang.String toString()
          Convert this Transform to a String.
 void transform(float[] source, int sourceOffset, float[] destination, int destOffset, int numberOfPoints)
          Transform the point pairs in the source array and store them in the destination array.
 Vector2f transform(Vector2f pt)
          Transform the vector2f based on the matrix defined in this transform
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Transform

public Transform()
Create and identity transform


Transform

public Transform(Transform other)
Copy a transform

Parameters:
other - The other transform to copy

Transform

public Transform(Transform t1,
                 Transform t2)
Concatanate to transform into one

Parameters:
t1 - The first transform to join
t2 - The second transform to join

Transform

public Transform(float[] matrixPosition)
Create a transform for the given positions

Parameters:
matrixPosition - An array of float[6] to set up a transform
Throws:
java.lang.RuntimeException - if the array is not of length 6

Transform

public Transform(float point00,
                 float point01,
                 float point02,
                 float point10,
                 float point11,
                 float point12)
Create a transform for the given positions

Parameters:
point00 - float for the first position
point01 - float for the second position
point02 - float for the third position
point10 - float for the fourth position
point11 - float for the fifth position
point12 - float for the sixth position
Method Detail

transform

public void transform(float[] source,
                      int sourceOffset,
                      float[] destination,
                      int destOffset,
                      int numberOfPoints)
Transform the point pairs in the source array and store them in the destination array. All operations will be done before storing the results in the destination. This way the source and destination array can be the same without worry of overwriting information before it is transformed.

Parameters:
source - Array of floats containing the points to be transformed
sourceOffset - Where in the array to start processing
destination - Array of floats to store the results.
destOffset - Where in the array to start storing
numberOfPoints - Number of points to be transformed
Throws:
java.lang.ArrayIndexOutOfBoundsException - if sourceOffset + numberOfPoints * 2 > source.length or the same operation on the destination array

concatenate

public Transform concatenate(Transform tx)
Update this Transform by concatenating the given Transform to this one.

Parameters:
tx - The Transfrom to concatenate to this one.
Returns:
The resulting Transform

toString

public java.lang.String toString()
Convert this Transform to a String.

Overrides:
toString in class java.lang.Object
Returns:
This Transform in human readable format.

getMatrixPosition

public float[] getMatrixPosition()
Get an array representing this Transform.

Returns:
an array representing this Transform.

createRotateTransform

public static Transform createRotateTransform(float angle)
Create a new rotation Transform

Parameters:
angle - The angle in radians to set the transform.
Returns:
The resulting Transform

createRotateTransform

public static Transform createRotateTransform(float angle,
                                              float x,
                                              float y)
Create a new rotation Transform around the specified point

Parameters:
angle - The angle in radians to set the transform.
x - The x coordinate around which to rotate.
y - The y coordinate around which to rotate.
Returns:
The resulting Transform

createTranslateTransform

public static Transform createTranslateTransform(float xOffset,
                                                 float yOffset)
Create a new translation Transform

Parameters:
xOffset - The amount to move in the x direction
yOffset - The amount to move in the y direction
Returns:
The resulting Transform

createScaleTransform

public static Transform createScaleTransform(float xScale,
                                             float yScale)
Create an new scaling Transform

Parameters:
xScale - The amount to scale in the x coordinate
yScale - The amount to scale in the x coordinate
Returns:
The resulting Transform

transform

public Vector2f transform(Vector2f pt)
Transform the vector2f based on the matrix defined in this transform

Parameters:
pt - The point to be transformed
Returns:
The resulting point transformed by this matrix


Copyright © 2006 New Dawn Software. All Rights Reserved.