maspack.geometry

## Class AffineTransformer

• ```public class AffineTransformer
extends GeometryTransformer```
A GeometryTransformer that implements a linear affine transformation. For points, this can be expressed in homogenous coordinates as
```
[ p' ]     [ p ]       [  F   pf  ]
[    ] = X [   ],  X = [          ]
[ 1  ]     [ 1 ]       [  0    1  ]
```
where F is a general 3 X 3 matrix and pf is an offset vector.
Author:
John E Lloyd

• ### Nested classes/interfaces inherited from class maspack.geometry.GeometryTransformer

`GeometryTransformer.Constrainer, GeometryTransformer.UndoState, GeometryTransformer.UniformScalingConstrainer`
• ### Constructor Summary

Constructors
Constructor and Description
`AffineTransformer(AffineTransform3d X)`
Creates a new AffineTransformer from a specified affine transform.
• ### Method Summary

All Methods
Modifier and Type Method and Description
`void` ```computeLocalTransforms(Matrix3d PL, Vector3d Ndiag, RigidTransform3d T)```
Computes the matrices `PL` and `N` that transform points `xl` local to a coordinate frame `T` after that frame is itself transformed.
`void` ```computeTransform(AffineTransform3d XR, AffineTransform3d X)```
Transforms an affine transform `X` and returns the result in `XR`.
`void` ```computeTransform(Matrix3d MR, Matrix3d M, Vector3d r)```
Transforms a general 3 X 3 matrix `M` and returns the result in `MR`.
`void` ```computeTransform(Plane pr, Plane p, Vector3d r)```
Transforms a plane `p` and returns the result in `pr`.
`void` ```computeTransform(RotationMatrix3d RR, Vector3d Ndiag, RotationMatrix3d R, Vector3d r)```
Transforms a rotation matrix `R` and returns the result in `RR`.
`void` ```computeTransformNormal(Vector3d nr, Vector3d n, Vector3d r)```
Transforms a normal vector `n`, and returns the result in `nr`.
`void` ```computeTransformPnt(Point3d pr, Point3d p)```
Transforms a point `p` and returns the result in `pr`.
`void` ```computeTransformVec(Vector3d vr, Vector3d v, Vector3d r)```
Transforms a vector `v`, and returns the result in `vr`.
`AffineTransformer` `getInverse()`
Returns a transformer that implements the inverse operation of this transformer.
`boolean` `isAffine()`
Returns `true`, since this transformer does implement a linear affine transform.
`boolean` `isInvertible()`
Returns `true`, since this transformer is invertible.
`boolean` `isReflecting()`
Returns `true` if this transformer is reflecting.
`boolean` `isRigid()`
Returns `false`, since this transformer does not implement a linear rigid transform.
• ### Methods inherited from class maspack.geometry.GeometryTransformer

`computeLinearizedTransform, computeLocalAffineTransform, computeTransform, create, getUndoDataSize, isRestoring, isSaving, popRestoreData, restoreObject, saveObject, setUndoState, transform, transform, transform, transform, transform, transform, transform, transform, transform, transform, transform, transform, transformNormal, transformNormal, transformPnt, transformPnt, transformVec, transformVec, transformWorld, transformWorld`
• ### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Constructor Detail

• #### AffineTransformer

`public AffineTransformer(AffineTransform3d X)`
Creates a new AffineTransformer from a specified affine transform.
Parameters:
`X` - affine transform defining the transformation
• ### Method Detail

• #### isRigid

`public boolean isRigid()`
Returns `false`, since this transformer does not implement a linear rigid transform.
Specified by:
`isRigid` in class `GeometryTransformer`
• #### isAffine

`public boolean isAffine()`
Returns `true`, since this transformer does implement a linear affine transform.
Specified by:
`isAffine` in class `GeometryTransformer`
• #### isReflecting

`public boolean isReflecting()`
Returns `true` if this transformer is reflecting.
Overrides:
`isReflecting` in class `GeometryTransformer`
• #### isInvertible

`public boolean isInvertible()`
Returns `true`, since this transformer is invertible.
Specified by:
`isInvertible` in class `GeometryTransformer`
• #### getInverse

`public AffineTransformer getInverse()`
Returns a transformer that implements the inverse operation of this transformer.
Specified by:
`getInverse` in class `GeometryTransformer`
Returns:
inverse transformer
• #### computeTransformPnt

```public void computeTransformPnt(Point3d pr,
Point3d p)```
Transforms a point `p` and returns the result in `pr`. The transform is computed according to
``` pr = F p + pf
```
This method provides the low level implementation for point transformations and does not do any saving or restoring of data.
Specified by:
`computeTransformPnt` in class `GeometryTransformer`
Parameters:
`pr` - transformed point
`p` - point to be transformed
• #### computeTransformVec

```public void computeTransformVec(Vector3d vr,
Vector3d v,
Vector3d r)```
Transforms a vector `v`, and returns the result in `vr`. The reference position `r` is ignored since affine transforms are position invariant. The transform is computed according to
``` vr = F v
```
This method provides the low level implementation for vector transformations and does not do any saving or restoring of data.
Specified by:
`computeTransformVec` in class `GeometryTransformer`
Parameters:
`vr` - transformed vector
`v` - vector to be transformed
`r` - reference position of the vector (ignored)
• #### computeLocalTransforms

```public void computeLocalTransforms(Matrix3d PL,
Vector3d Ndiag,
RigidTransform3d T)```
Computes the matrices `PL` and `N` that transform points `xl` local to a coordinate frame `T` after that frame is itself transformed. The updated local coordinates are given by
``` xl' = N PL xl
```
where `PL` is symmetric positive definite and `N` is a diagonal matrix that is either the identity, or a reflection that flips a single axis. See the documentation for `GeometryTransformer.computeLocalTransforms(maspack.matrix.Matrix3d, maspack.matrix.Vector3d, maspack.matrix.RigidTransform3d)`. The quantities `F` and `f(p)` described there correspond to `F` and `pf` for this transformer.
Specified by:
`computeLocalTransforms` in class `GeometryTransformer`
Parameters:
`PL` - primary transformation matrix
`Ndiag` - if non-null, returns the diagonal components of N
`T` - rigid transform for which the local transforms are computed
• #### computeTransformNormal

```public void computeTransformNormal(Vector3d nr,
Vector3d n,
Vector3d r)```
Transforms a normal vector `n`, and returns the result in `nr`. The reference position `r` is ignored since affine transforms are position invariant. The transform is computed according to
```       -1 T
nr = F     n
```
The result is not normalized since the unnormalized form could be useful in some contexts. This method provides the low level implementation for normal transformations and does not do any saving or restoring of data.
Specified by:
`computeTransformNormal` in class `GeometryTransformer`
Parameters:
`nr` - transformed normal
`n` - normal to be transformed
`r` - reference position of the normal (ignored)
• #### computeTransform

```public void computeTransform(AffineTransform3d XR,
AffineTransform3d X)```
Transforms an affine transform `X` and returns the result in `XR`. If
```     [  A  p ]
X = [       ]
[  0  1 ]
```
the transform is computed according to
```      [  F A   F p + pf ]
XR = [                 ]
[   0       1     ]
```
This method provides the low level implementation for the transformation of affine transforms and does not do any saving or restoring of data.
Specified by:
`computeTransform` in class `GeometryTransformer`
Parameters:
`XR` - transformed transform
`X` - transform to be transformed
• #### computeTransform

```public void computeTransform(RotationMatrix3d RR,
Vector3d Ndiag,
RotationMatrix3d R,
Vector3d r)```
Transforms a rotation matrix `R` and returns the result in `RR`. The reference position `r` is ignored since affine transforms are position invariant. This transform takes the form
``` RR = Q R N
```
where `Q` is the orthogonal matrix from the left polar decomposition `F = P Q`, and `N` is matrix that flips an axis to ensure that `Q R N` remains right-handed. For additional details, see the documentation for `transform(RR,R,r)`. This method provides the low level implementation for the transformation of rotation matrices and does not do any saving or restoring of data.
Specified by:
`computeTransform` in class `GeometryTransformer`
Parameters:
`RR` - transformed rotation
`R` - rotation to be transformed
`r` - reference position of the rotation (ignored)
`Ndiag` - if non-null, returns the diagonal elements of the matrix `N`
• #### computeTransform

```public void computeTransform(Matrix3d MR,
Matrix3d M,
Vector3d r)```
Transforms a general 3 X 3 matrix `M` and returns the result in `MR`. The reference position `r` is ignored since affine transforms are position invariant. The transform is computed according to
``` MR = F M
```
This method provides the low level implementation for the transformation of 3 X 3 matrices and does not do any saving or restoring of data.
Specified by:
`computeTransform` in class `GeometryTransformer`
Parameters:
`MR` - transformed matrix
`M` - matrix to be transformed
`r` - reference position of the matrix (ignored)
• #### computeTransform

```public void computeTransform(Plane pr,
Plane p,
Vector3d r)```
Transforms a plane `p` and returns the result in `pr`. The reference position `r` is ignored since affine transforms are position invariant. Assume that `p` is defined by a normal `n` and offset `o` such that all planar points `x` satisfy
``` n^T x = o
```
Then the transformed normal `nr` and offset `or` are computed according to
``` nr = inv(F)^T n
or = o + nr^T pf
mag = ||nr||
nr = nr/mag, or = or/mag
```
This method provides the low level implementation for the transformation of planes and does not do any saving or restoring of data.
Specified by:
`computeTransform` in class `GeometryTransformer`
Parameters:
`pr` - transformed plane
`p` - plane to be transformed
`r` - reference position of the plane (ignored)