maspack.matrix

## Class PolarDecomposition3d

• java.lang.Object
• maspack.matrix.PolarDecomposition3d

• ```public class PolarDecomposition3d
extends java.lang.Object```
Class to produce the polar decompositions of a 3x3 matrix. The right polar decomposition of a matrix M is produced by the `factor(maspack.matrix.Matrix3dBase)` method and is given by
``` M = Q P
```
where `Q` is orthogonal and `P` is symmetric positive definite (or indefinite if `M` is singular). Note that `Q` is not necessarily right-handed. It is possible to define an alternative decomposition,
``` M = R H
```
where `R` is a right-handed rotation matrix and `H` is symmetric indefinite. Alternatively, if `Q` is not right-handed, one can make it so by negating one of its axes, using
``` Q' = Q N
```
where `N` is a diagonal matrix whose elements are either 1 or -1 and whose determinant is -1. At present, this class chooses `N` with a single -1 at the same location as the diagonal element of `Q` that is nearest to 1. The idea here is to flip the single axis that is least affected by `Q`.

The left polar decomposition is produced by the `factorLeft(maspack.matrix.Matrix3dBase)` method and is given by

``` M = P Q
```
with the alternative decomposition,
``` M = H R
```
Note that the `Q` and `R` matrices associated with the right and left factorizations are identical, whereas the `P` and `H` matrices are not.
• ### Constructor Summary

Constructors
Constructor and Description
`PolarDecomposition3d()`
`PolarDecomposition3d(Matrix3dBase M)`
• ### Method Summary

All Methods
Modifier and Type Method and Description
`void` `factor(Matrix3dBase M)`
`void` `factorLeft(Matrix3dBase M)`
`void` `getH(Matrix3d H)`
`int` `getMaxQDiagIndex()`
Returns the index of the maximum diagonal element of `Q`.
`void` `getN(Vector3d Ndiag)`
Return the diagonal elements of the matrix `N` which is used to flip rows or columns of `Q` (or some product thereof) in the event that `Q` is not right-handed.
`Matrix3d` `getP()`
`void` `getP(Matrix3d P)`
`Matrix3d` `getQ()`
`void` `getQ(Matrix3d Q)`
`RotationMatrix3d` `getR()`
`void` `getR(Matrix3dBase R)`
`void` `getSig(Vector3d sig)`
`Matrix3d` `getV()`
`boolean` `isRightHanded()`
`void` `makeRightHanded(RotationMatrix3d R)`
Flip an axis of R in order to make it right-handed.
• ### Methods inherited from class java.lang.Object

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

• #### PolarDecomposition3d

`public PolarDecomposition3d()`
• #### PolarDecomposition3d

`public PolarDecomposition3d(Matrix3dBase M)`
• ### Method Detail

• #### factor

`public void factor(Matrix3dBase M)`
• #### factorLeft

`public void factorLeft(Matrix3dBase M)`
• #### getR

`public RotationMatrix3d getR()`
• #### getR

`public void getR(Matrix3dBase R)`
• #### getQ

`public Matrix3d getQ()`
• #### getQ

`public void getQ(Matrix3d Q)`
• #### getH

`public void getH(Matrix3d H)`
• #### getP

`public Matrix3d getP()`
• #### getP

`public void getP(Matrix3d P)`
• #### getV

`public Matrix3d getV()`
• #### getSig

`public void getSig(Vector3d sig)`
• #### isRightHanded

`public boolean isRightHanded()`
• #### getN

`public void getN(Vector3d Ndiag)`
Return the diagonal elements of the matrix `N` which is used to flip rows or columns of `Q` (or some product thereof) in the event that `Q` is not right-handed. If `det(Q) == 1`, then `N` is the identity matrix. Otherwise, if `det(Q) = -1`, then `N` flips the column corresponding to the diagonal element of `Q` which is nearest to 1.
Parameters:
`Ndiag` - returns the diagonal elements of `N`.
• #### getMaxQDiagIndex

`public int getMaxQDiagIndex()`
Returns the index of the maximum diagonal element of `Q`. This is used to create the matrix `N` which is returned by `getN(maspack.matrix.Vector3d)`.
Returns:
index of the maximum diagonal element of `Q`.
• #### makeRightHanded

`public void makeRightHanded(RotationMatrix3d R)`
Flip an axis of R in order to make it right-handed. The axis chosen is one that was transformed *least* by Q, which will correspond to a diagonal Q element nearest to 1.
Parameters:
`R` - unitary matrix