|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.tensegrity.generic.math.Transform2D
The Transform2D class is responsible for implementing affine
transformations http://en.wikipedia.org/wiki/Affine_transformation
in 2-dimensional space. Affine transformations involve scaling, translating,
rotating and sheering.
Any number of affine transformations can be accumulated into a single combined transformation and then applied to any number of coordinates with much lower cost than if all single transformations were applied separately. This is a common and practical scenario. For example, rotating a point P by an angle alpha around an axis of rotation that is not the center of the coordinate system can be achieved by the following sequence of affine transformations:
Important properties of affine transformations include:
invert() method on a Transform2D
instance. The transformation will be inverted by bringing any previously
transformed points back to their original positions.
Transform2D that is orthogonal (for example
it consists only of rotation transformation), you can invert it more
efficiently by invoking the transpose() method.
Transform2D is orthogonal or not by
evaluating the return value of method determinant().
All calculations made are based upon a Matrix33D instance. The main
advantages of this class are the many overloaded apply methods
offered.
Matrix33D| Constructor Summary | |
Transform2D()
Constructs a 2d transform and initializes this transform to the identity transform. |
|
Transform2D(double v00,
double v01,
double v02,
double v10,
double v11,
double v12)
Contructs an affine transform from only the 6 relevant parameters. |
|
Transform2D(double v00,
double v01,
double v02,
double v10,
double v11,
double v12,
double v20,
double v21,
double v22)
Contructs an affine transform by means of all 9 parameters. |
|
Transform2D(Matrix33D matrix)
Constructs by copying the values from a given matrix into this transform. |
|
Transform2D(Transform2D transform)
Constructs by copying the values from another transform into this transform. |
|
| Method Summary | |
void |
apply(double[] points)
Applies this transform inplace to a number of points which are stored in an array of doubles. |
void |
apply(double[] in,
double[] out)
Applies this transform to a number of points which are stored in an array of doubles. |
void |
apply(float[] points)
Applies this transform inplace to a number of points which are stored in an array of doubles. |
void |
apply(float[] in,
float[] out)
Applies this transform to a number of points which are stored in an array of doubles. |
void |
apply(int[] points)
Applies this transform inplace to a number of points which are stored in an array of integers. |
void |
apply(int[] in,
int[] out)
Applies this transform to a number of points which are stored in an array of integers. |
void |
apply(Vector2 vector)
Applies this transform in place to a vector2. |
void |
apply(Vector2 in,
Vector2 out)
Applies this transform to a Vector2. |
void |
apply2(double[] inOutX,
double[] inOutY)
Applies this transform inplace to a number of points whose X and Y coordinates are stored in two arrays. |
void |
apply2(double[] inX,
double[] inY,
double[] outX,
double[] outY)
Applies this transform to a number of points whose X and Y coordinates are stored in two arrays. |
void |
apply2(float[] inX,
float[] inY)
Applies this transform inplace to a number of points whose X and Y coordinates are stored in two arrays. |
void |
apply2(float[] inX,
float[] inY,
float[] outX,
float[] outY)
Applies this transform to a number of points whose X and Y coordinates are stored in two arrays. |
void |
apply2(int[] inX,
int[] inY)
Applies this transform inplace to a number of points whose X and Y coordinates are stored in two arrays. |
void |
apply2(int[] inX,
int[] inY,
int[] outX,
int[] outY)
Applies this transform to a number of points whose X and Y coordinates are stored in two arrays. |
void |
combine(Transform2D transform)
Multiplies another transform onto this transform, thereby combined the affine transforms into an accumulated form. |
static Transform2D |
combine(Transform2D xform1,
Transform2D xform2)
Combines the two given transformations to one transformation. |
static Transform2D |
combineInverse(Transform2D xform1,
Transform2D xform2)
Combines the inverse transformations of the two given transformations to one transformation. |
static Transform2D |
createRotation(double angle)
Conveniece method that creates a new rotation transform. |
static Transform2D |
createScale(double sx,
double sy)
Conveniece method that creates a new scaling transform. |
static Transform2D |
createTranslation(double dx,
double dy)
Conveniece method that creates a new translation transform. |
double |
determinant()
Returns the determinant of the matrix of this transform. |
boolean |
equalsTransform(Transform2D transform)
Returns true, if the two transforms contain the same elements (Object.equals wasn't overridden to prevent unexpected behavior) |
Matrix33D |
getMatrix33D()
Returns the matrix 33d of this transform. |
void |
getSpecifiableMatrix(double[] flatmatrix)
Retrieves the 6 specifiable values of the transformation. |
void |
invert()
Inverts this transform. |
void |
rotate(double angle)
Concatenates a rotation transform onto this transform |
void |
scale(double sx,
double sy)
Concatenates a scaling transform onto this transform |
void |
set(double v00,
double v01,
double v02,
double v10,
double v11,
double v12)
Sets an affine transform from only the 6 relevant parameters. |
void |
set(Matrix33D matrix)
Sets this transform to the specified matrix. |
void |
set(Transform2D transform)
Sets this transform to the specified transform. |
void |
setToIdentity()
Sets this instance to the identity-transform. |
void |
setToRotation(double angle)
Sets transform to rotation transform. |
void |
setToScale(double sx,
double sy)
Sets transform to a scaling transform. |
void |
setToTranslation(double dx,
double dy)
Sets transform to a translation transform. |
java.lang.String |
toString()
Returns a string representation of this transform in flat matrix like structure. |
java.lang.String |
toStringMatrixLike(java.lang.String indent)
Returns a string representation of this transform in matrix like structure. |
void |
translate(double tx,
double ty)
Concatenates a translation transform onto this transform |
void |
transpose()
Transposes this transform. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public Transform2D()
public Transform2D(Matrix33D matrix)
matrix - the source-matrix to be copied.public Transform2D(Transform2D transform)
transform - the source-transform to be copied.
public Transform2D(double v00,
double v01,
double v02,
double v10,
double v11,
double v12,
double v20,
double v21,
double v22)
v00 - value for row 0, column 0v01 - value for row 0, column 1v02 - value for row 0, column 2v10 - value for row 1, column 0v11 - value for row 1, column 1v12 - value for row 1, column 2v20 - value for row 2, column 0v21 - value for row 2, column 1v22 - value for row 2, column 2
public Transform2D(double v00,
double v01,
double v02,
double v10,
double v11,
double v12)
v00 - value for row 0, column 0v01 - value for row 0, column 1v02 - value for row 0, column 2v10 - value for row 1, column 0v11 - value for row 1, column 1v12 - value for row 1, column 2| Method Detail |
public final void set(double v00,
double v01,
double v02,
double v10,
double v11,
double v12)
v00 - value for row 0, column 0v01 - value for row 0, column 1v02 - value for row 0, column 2v10 - value for row 1, column 0v11 - value for row 1, column 1v12 - value for row 1, column 2public final void set(Matrix33D matrix)
matrix - the matrix to set this transform to.public final void getSpecifiableMatrix(double[] flatmatrix)
flatmatrix - the double array used to store the returned
values.public final void set(Transform2D transform)
transform - the transform to copy into this instance.public final void setToIdentity()
public final void setToTranslation(double dx,
double dy)
dx - translation in direction.dy - translation in y direction.
public final void setToScale(double sx,
double sy)
sx - scaling in x direction.sy - scaling in y direction.public final void setToRotation(double angle)
angle - rotation in degrees in counter clockwise direction.
public final void translate(double tx,
double ty)
tx - translation in direction.ty - translation in y direction.
public final void scale(double sx,
double sy)
sx - scaling in x direction.sy - scaling in y direction.public final void rotate(double angle)
angle - rotation in degrees in counter clockwise direction.public final void combine(Transform2D transform)
transform - the transform to combine with this one.public final double determinant()
public final void invert()
throws MathException
MathException - thrown if this transform is not invertible.public final void transpose()
public final void apply(int[] in,
int[] out)
in - the array of points to transform, where x-coordinates are
stored at even positions and y-coordinates are stored at
odd positions.out - the array in which to store the transformed points.public final void apply(int[] points)
points - the array of points to transform, where x coordinates
are stored at even positions and y coordinates are
stored at odd positions.
public final void apply(float[] in,
float[] out)
in - the array of points to transform, where x coordinates are
stored at even positions and y coordinates are stored at odd
positions.out - the array where to store the transformed points.public final void apply(float[] points)
points - the array of points to transform, where x coordinates
are stored at even positions and y coordinates are
stored at odd positions.
public final void apply(double[] in,
double[] out)
in - the array of points to transform, where x coordinates are
stored at even positions and y coordinates are stored at odd
positions.out - the array where to store the transformed points.public final void apply(double[] points)
points - the array of points to transform, where x coordinates
are stored at even positions and y coordinates are
stored at odd positions.
public final void apply2(int[] inX,
int[] inY,
int[] outX,
int[] outY)
inX - the array of X coordinates of the points to transform.inY - the array of Y coordinates of the points to transform.outX - the array where to store the transformed X coordinates.outY - the array where to store the transformed Y coordinates.
public final void apply2(int[] inX,
int[] inY)
inX - the array of X coordinates of the points to transform.inY - the array of Y coordinates of the points to transform.
public final void apply2(float[] inX,
float[] inY,
float[] outX,
float[] outY)
inX - the array of X coordinates of the points to transform.inY - the array of Y coordinates of the points to transform.outX - the array where to store the transformed X coordinates.outY - the array where to store the transformed Y coordinates.
public final void apply2(float[] inX,
float[] inY)
inX - the array of X coordinates of the points to transform.inY - the array of Y coordinates of the points to transform.
public final void apply2(double[] inX,
double[] inY,
double[] outX,
double[] outY)
inX - the array of X coordinates of the points to transform.inY - the array of Y coordinates of the points to transform.outX - the array where to store the transformed X coordinates.outY - the array where to store the transformed Y coordinates.
public final void apply2(double[] inOutX,
double[] inOutY)
inOutX - the array of X coordinates of the points to transform.inOutY - the array of Y coordinates of the points to transform.
public final void apply(Vector2 in,
Vector2 out)
Vector2.
in - the source Vector2.out - the target Vector2.public final void apply(Vector2 vector)
vector - the Vector2.
public static final Transform2D createTranslation(double dx,
double dy)
dx - translation in direction.dy - translation in y direction.
public static final Transform2D createScale(double sx,
double sy)
sx - scaling in x direction.sy - scaling in y direction.
public static final Transform2D createRotation(double angle)
angle - rotation in degrees in counter clockwise direction.
public static Transform2D combine(Transform2D xform1,
Transform2D xform2)
Transform2D instance if both given
transformations are not null
xform1 - the first transformxform2 - the second transform
Transform2D the combined transform
public static Transform2D combineInverse(Transform2D xform1,
Transform2D xform2)
throws MathException
Transform2D instance if both given
transformations are not null
xform1 - the first transformxform2 - the second transform
MathException - thrown if this transform is not invertible.public Matrix33D getMatrix33D()
public boolean equalsTransform(Transform2D transform)
transform - the Transform2D to check
public java.lang.String toString()
public java.lang.String toStringMatrixLike(java.lang.String indent)
indent - optional indent for the matrix like representation
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||