maspack.matrix
Class AffineTransform2dObject

java.lang.Object
  extended bymaspack.matrix.MatrixObject
      extended bymaspack.matrix.AffineTransform2dObject
Direct Known Subclasses:
AffineTransform2d, RigidTransform2d

public class AffineTransform2dObject
extends MatrixObject

Base class for 3 x 3 matrices representing 2D affine transformations. A 2D affine transformation applied to a 2-vector v has the form
A v + b
In homogeneous coordinates, this is represented by a 3 x 3 matrix of the form

     [  A   p  ]
 M = [         ]
     [  0   1  ]
 


Constructor Summary
AffineTransform2dObject()
           
 
Method Summary
 int colSize()
          Returns the number of columns in this matrix (which is always 3).
 boolean epsilonEquals(AffineTransform2dObject X, double epsilon)
          Returns true if the elements of this transformation equal those of transform X1within a prescribed tolerance epsilon.
 boolean equals(AffineTransform2dObject X)
          Returns true if the elements of this transformation exactly equal those of transform X1.
 void get(double[] values)
          Copies the elements of this matrix into an array of doubles. The elements are stored using row-major order, so that element (i,j) is stored at location i*colSize()+j.
 double get(int i, int j)
          Gets a single element of this matrix.
 void getColumn(int j, double[] values)
          Copies a column of this matrix into an array of doubles.
 void getRow(int i, double[] values)
          Copies a row of this matrix into an array of doubles.
 boolean invert()
          Inverts this transform in place.
 void mul(Vector3d vr)
          Multiplies the column vector vr by this transform and places the result back in vr.
 void mul(Vector3d vr, Vector3d v1)
          Multiplies the column vector v1 by this transform and places the result in vr.
 boolean mulInverse(Vector3d vr)
          Multiplies the column vector vr by the inverse of this transform and places the result back in vr.
 boolean mulInverse(Vector3d vr, Vector3d v1)
          Multiplies the column vector v1 by the inverse of this transform and places the result in vr.
 int rowSize()
          Returns the number of rows in this matrix (which is always 3).
 void set(double[] vals)
          Sets the elements of this matrix from an array of doubles. The elements in the array should be stored using row-major order, so that element (i,j) is stored at location i*colSize()+j.
 void set(int i, int j, double value)
          Sets a single element of this matrix.
 void set(RigidTransform2d X)
          Sets this affine transform to the rigid body transform described by X.
 void setColumn(int j, double[] values)
          Sets a column of this matrix from an array of doubles.
 void setIdentity()
          Sets the transformation to the identity.
 void setRow(int i, double[] values)
          Set a row of this matrix from an array of doubles.
 
Methods inherited from class maspack.matrix.MatrixObject
determinant, epsilonEquals, equals, equals, frobeniusNorm, get, getColumn, getRow, infinityNorm, isFixedSize, oneNorm, scan, set, set, setColumn, setRow, setSize, toString, toString, toString
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AffineTransform2dObject

public AffineTransform2dObject()
Method Detail

colSize

public int colSize()
Returns the number of columns in this matrix (which is always 3).

Specified by:
colSize in class MatrixObject
Returns:
3

rowSize

public int rowSize()
Returns the number of rows in this matrix (which is always 3).

Specified by:
rowSize in class MatrixObject
Returns:
3

get

public double get(int i,
                  int j)
Gets a single element of this matrix.

Specified by:
get in class MatrixObject
Parameters:
i - element row index
j - element column index
Returns:
element value

get

public void get(double[] values)
Copies the elements of this matrix into an array of doubles. The elements are stored using row-major order, so that element (i,j) is stored at location i*colSize()+j.

Overrides:
get in class MatrixObject
Parameters:
values - array into which values are copied

getColumn

public void getColumn(int j,
                      double[] values)
Copies a column of this matrix into an array of doubles.

Overrides:
getColumn in class MatrixObject
Parameters:
j - column index
values - array into which the column is copied

getRow

public void getRow(int i,
                   double[] values)
Copies a row of this matrix into an array of doubles.

Overrides:
getRow in class MatrixObject
Parameters:
i - row index
values - array into which the row is copied

set

public final void set(int i,
                      int j,
                      double value)
Sets a single element of this matrix.

Specified by:
set in class MatrixObject
Parameters:
i - element row index
j - element column index
value - element value

set

public void set(double[] vals)
Sets the elements of this matrix from an array of doubles. The elements in the array should be stored using row-major order, so that element (i,j) is stored at location i*colSize()+j.

Overrides:
set in class MatrixObject
Parameters:
vals - array from which values are copied

setColumn

public void setColumn(int j,
                      double[] values)
Sets a column of this matrix from an array of doubles.

Overrides:
setColumn in class MatrixObject
Parameters:
j - column index
values - array from which column values are copied

setRow

public void setRow(int i,
                   double[] values)
Set a row of this matrix from an array of doubles.

Overrides:
setRow in class MatrixObject
Parameters:
i - row index
values - array from which the row is copied

set

public void set(RigidTransform2d X)
Sets this affine transform to the rigid body transform described by X.

Parameters:
X - rigid body transform to copy

setIdentity

public void setIdentity()
Sets the transformation to the identity.


mul

public void mul(Vector3d vr,
                Vector3d v1)
Multiplies the column vector v1 by this transform and places the result in vr.

Parameters:
vr - result vector
v1 - vector to multiply

mul

public void mul(Vector3d vr)
Multiplies the column vector vr by this transform and places the result back in vr.

Parameters:
vr - vector to multiply (in place)

mulInverse

public boolean mulInverse(Vector3d vr,
                          Vector3d v1)
Multiplies the column vector v1 by the inverse of this transform and places the result in vr.

Parameters:
vr - result vector
v1 - vector to multiply
Returns:
false if this transform is singular

mulInverse

public boolean mulInverse(Vector3d vr)
Multiplies the column vector vr by the inverse of this transform and places the result back in vr.

Parameters:
vr - vector to multiply (in place)
Returns:
false if this transform is singular

invert

public boolean invert()
Inverts this transform in place.

Returns:
false if this transform is singular

epsilonEquals

public boolean epsilonEquals(AffineTransform2dObject X,
                             double epsilon)
Returns true if the elements of this transformation equal those of transform X1within a prescribed tolerance epsilon.

Parameters:
X - transform to compare with
epsilon - comparison tolerance
Returns:
false if the transforms are not equal within the specified tolerance

equals

public boolean equals(AffineTransform2dObject X)
Returns true if the elements of this transformation exactly equal those of transform X1.

Parameters:
X - transform to compare with
Returns:
false if the transforms are not equal