maspack.matrix
Class RigidTransform2d

java.lang.Object
  extended by maspack.matrix.MatrixBase
      extended by maspack.matrix.DenseMatrixBase
          extended by maspack.matrix.AffineTransform2dBase
              extended by maspack.matrix.RigidTransform2d
All Implemented Interfaces:
DenseMatrix, LinearTransformNd, Matrix

public class RigidTransform2d
extends AffineTransform2dBase

A specialized 3 x 3 matrix that implements a two-dimensional rigid body transformation in homogeneous coordinates.

A rigid body transformation is used to transform a point from one spatial coordinate frame into another. If x0 and x1 denote the point in the orginal frame 0 and target frame 1, respectively, then the transformation is computed according to

 x1 = R x0 + p
 
where R is a 2 x 2 rotation matrix and p is a translation vector. In homogenous coordinates, this operation can be represented as
 [ x1 ]   [ R  p ] [ x0 ]
 [    ] = [      ] [    ]
 [  1 ]   [ 0  1 ] [  1 ]
 
The components p and R of the transformation represent the position and orientation of frame 0 with respect to frame 1. In particular, the translation vector p gives the origin position, while the columns of R give the directions of the axes.

If X01 is a transformation from frame 0 to frame 1, and X12 is a transformation from frame 1 to frame 2, then the transformation from frame 0 to frame 2 is given by the product

 X02 = X12 X01
 
In this way, a transformation can be created by multiplying a series of sub-transformations.

If X01 is a transformation from frame 0 to frame 1, then the inverse transformation X10 is a transformation from frame 1 to frame 0, and is given by

       [  T    T   ]
       [ R   -R  p ]
 X10 = [           ]
       [ 0     1   ]
 


Nested Class Summary
 
Nested classes/interfaces inherited from interface maspack.matrix.Matrix
Matrix.Partition, Matrix.WriteFormat
 
Field Summary
static RigidTransform2d IDENTITY
          Global identity transform.
 Vector2d p
          Translation vector associated with this transformation.
 RotationMatrix2d R
          Rotation matrix associated with this transformation.
 
Fields inherited from interface maspack.matrix.Matrix
INDEFINITE, POSITIVE_DEFINITE, SPD, SYMMETRIC
 
Constructor Summary
RigidTransform2d()
          Creates a new transformation initialized to the identity.
RigidTransform2d(double x, double y, double ang)
          Creates a new transformation with the specified translation values and rotation angle
RigidTransform2d(RigidTransform2d X)
          Creates a new transformation which is a copy of an existing one.
RigidTransform2d(Vector2d p, double ang)
          Creates a new transformation with the specified translation vector and rotation angle
RigidTransform2d(Vector2d p, RotationMatrix2d R)
          Creates a new transformation with the specified translation vector and rotation matrix.
 
Method Summary
 void fit(java.util.ArrayList<Point2d> p, java.util.ArrayList<Point2d> q)
           
 void fit(java.util.ArrayList<Point2d> p, java.util.ArrayList<Point2d> q, boolean doScaling)
          Sets this rigid transform to one that provides the best fit of q to p in the least-squares sense: p ~ X q
 boolean invert()
          Inverts this transform in place.
 boolean invert(RigidTransform2d X)
          Inverts transform X and places the result in this transform.
 void mul(RigidTransform2d X)
          Post-multiplies this transformation by another and places the result in this transformation.
 void mul(RigidTransform2d X1, RigidTransform2d X2)
          Multiplies transformation X1 by X2 and places the result in this transformation.
 void mulInverse(RigidTransform2d X)
          Post-multiplies this transformation by the inverse of transformation X and places the result in this transformation.
 boolean mulInverse(Vector3d vr, Vector3d v1)
          Multiplies the column vector v1 by the inverse of this transform and places the result in vr.
 void mulInverseBoth(RigidTransform2d X1, RigidTransform2d X2)
          Multiplies the inverse of transformation X1 by the inverse of transformation X2 and places the result in this transformation.
 void mulInverseLeft(RigidTransform2d X1, RigidTransform2d X2)
          Multiplies the inverse of transformation X1 by transformation X2 and places the result in this transformation.
 void mulInverseRight(RigidTransform2d X1, RigidTransform2d X2)
          Multiplies transformation X1 by the inverse of transformation X2 and places the result in this transformation.
 
Methods inherited from class maspack.matrix.AffineTransform2dBase
colSize, epsilonEquals, equals, get, get, getColumn, getColumn, getRow, getRow, mul, mul, mulInverse, rowSize, set, set, set, setColumn, setIdentity, setRow
 
Methods inherited from class maspack.matrix.DenseMatrixBase
add, checkConsistency, set, set, set, set, setCCSValues, setColumn, setCRSValues, setRow, setSubMatrix
 
Methods inherited from class maspack.matrix.MatrixBase
containsNaN, determinant, epsilonEquals, equals, frobeniusNorm, get, getCCSIndices, getCCSIndices, getCCSValues, getCCSValues, getColumn, getCRSIndices, getCRSIndices, getCRSValues, getCRSValues, getDefaultFormat, getRow, getSize, getSubMatrix, hasNaN, idString, infinityNorm, isFixedSize, isSymmetric, mul, mul, mul, mulAdd, mulAdd, mulAdd, mulTranspose, mulTranspose, mulTranspose, mulTransposeAdd, mulTransposeAdd, mulTransposeAdd, numNonZeroVals, numNonZeroVals, oneNorm, scan, setCRSValues, setDefaultFormat, setSize, toString, toString, toString, trace, write, write, write, write, write, writeToFile
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface maspack.matrix.Matrix
determinant, epsilonEquals, equals, frobeniusNorm, getCCSIndices, getCCSIndices, getCCSValues, getCCSValues, getColumn, getCRSIndices, getCRSIndices, getCRSValues, getCRSValues, getRow, getSize, getSubMatrix, infinityNorm, isFixedSize, isSymmetric, mul, mul, mul, mulAdd, mulAdd, mulAdd, mulTranspose, mulTranspose, mulTranspose, mulTransposeAdd, mulTransposeAdd, mulTransposeAdd, numNonZeroVals, numNonZeroVals, oneNorm, scan, setSize, toString, trace, write, write, write
 

Field Detail

IDENTITY

public static final RigidTransform2d IDENTITY
Global identity transform. Should not be modified.


R

public final RotationMatrix2d R
Rotation matrix associated with this transformation.


p

public final Vector2d p
Translation vector associated with this transformation.

Constructor Detail

RigidTransform2d

public RigidTransform2d()
Creates a new transformation initialized to the identity.


RigidTransform2d

public RigidTransform2d(Vector2d p,
                        RotationMatrix2d R)
Creates a new transformation with the specified translation vector and rotation matrix.

Parameters:
p - translation vector
R - rotation matrix

RigidTransform2d

public RigidTransform2d(Vector2d p,
                        double ang)
Creates a new transformation with the specified translation vector and rotation angle

Parameters:
p - translation vector
ang - rotation angle (radians)

RigidTransform2d

public RigidTransform2d(double x,
                        double y,
                        double ang)
Creates a new transformation with the specified translation values and rotation angle

Parameters:
x - translation x component
y - translation y component
ang - rotation angle (radians)

RigidTransform2d

public RigidTransform2d(RigidTransform2d X)
Creates a new transformation which is a copy of an existing one.

Parameters:
X - transform to copy
Method Detail

mul

public void mul(RigidTransform2d X)
Post-multiplies this transformation by another and places the result in this transformation.

Parameters:
X - transformation to multiply by

mul

public void mul(RigidTransform2d X1,
                RigidTransform2d X2)
Multiplies transformation X1 by X2 and places the result in this transformation.

Parameters:
X1 - first transformation
X2 - second transformation

mulInverse

public void mulInverse(RigidTransform2d X)
Post-multiplies this transformation by the inverse of transformation X and places the result in this transformation.

Parameters:
X - right-hand transformation

mulInverseRight

public void mulInverseRight(RigidTransform2d X1,
                            RigidTransform2d X2)
Multiplies transformation X1 by the inverse of transformation X2 and places the result in this transformation.

Parameters:
X1 - left-hand transformation
X2 - right-hand transformation

mulInverseLeft

public void mulInverseLeft(RigidTransform2d X1,
                           RigidTransform2d X2)
Multiplies the inverse of transformation X1 by transformation X2 and places the result in this transformation.

Parameters:
X1 - left-hand transformation
X2 - right-hand transformation

mulInverseBoth

public void mulInverseBoth(RigidTransform2d X1,
                           RigidTransform2d X2)
Multiplies the inverse of transformation X1 by the inverse of transformation X2 and places the result in this transformation.

Parameters:
X1 - left-hand transformation
X2 - right-hand transformation

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.

Overrides:
mulInverse in class AffineTransform2dBase
Parameters:
vr - result vector
v1 - vector to multiply
Returns:
false if this transform is singular

invert

public boolean invert()
Inverts this transform in place.

Overrides:
invert in class AffineTransform2dBase
Returns:
true (transform is never singular)

invert

public boolean invert(RigidTransform2d X)
Inverts transform X and places the result in this transform.

Parameters:
X - transform to invert
Returns:
true (transform is never singular)

fit

public void fit(java.util.ArrayList<Point2d> p,
                java.util.ArrayList<Point2d> q,
                boolean doScaling)
         throws ImproperSizeException
Sets this rigid transform to one that provides the best fit of q to p in the least-squares sense: p ~ X q

Parameters:
p - set of target 2d points
q - set of input 2d points
doScaling - flag to apply uniform scaling in addition to rigid transform
Throws:
ImproperSizeException

fit

public void fit(java.util.ArrayList<Point2d> p,
                java.util.ArrayList<Point2d> q)
         throws ImproperSizeException
Throws:
ImproperSizeException