## org.opensourcephysics.numerics Class Matrix2DTransformation

```java.lang.Object
org.opensourcephysics.numerics.Matrix2DTransformation
```
All Implemented Interfaces:
java.lang.Cloneable, MatrixTransformation, Transformation

`public class Matrix2DTransformationextends java.lang.Objectimplements MatrixTransformation`

Matrix2DTransformation implements 2D affine transformations

Nested Class Summary
`protected static class` `Matrix2DTransformation.Matrix2DTransformationLoader`

Constructor Summary
`Matrix2DTransformation(java.awt.geom.AffineTransform transform)`
Constructor Matrix2DTransformation
`Matrix2DTransformation(double[][] matrix)`
Constructs a 2D transformation using the given matrix.

Method Summary
` java.lang.Object` `clone()`
Provides a copy of this transformation.
`static Matrix2DTransformation` ```createAlignmentTransformation(double[] v1, double[] v2)```
Instantiates a rotation that aligns the first vector with the second vector.
` double[]` `direct(double[] point)`
Transforms the given point+.
` double[]` `getFlatMatrix(double[] mat)`
Gets the direct homogeneous affine transformation flattened into a 1-d arrray.
`static XML.ObjectLoader` `getLoader()`

` java.awt.geom.AffineTransform` `getTotalTransform()`

` double[]` `inverse(double[] point)`
Transforms the given point using the inverse transformation (if it exists).
` void` `multiply(double[][] mat)`
Multiplies this rotation matrix by the given matrix.
` void` `multiply(Matrix2DTransformation trans)`
Multiplies (concatenates) this transformation matrix with the given transformation.
`static Matrix2DTransformation` `rotation(double theta)`
Creates a 2D transformation representing a rotation about the origin by the given angle.
`static Matrix2DTransformation` ```rotation(double theta, double anchorx, double anchory)```
Creates a 2D transformation representing a rotation about the origin by the given angle around the given axis.
` double[]` `setOrigin(double[] origin)`
Sets the origin for this rotation.
` void` ```setOrigin(double ox, double oy)```
Sets the origin for this rotation.

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Matrix2DTransformation

`public Matrix2DTransformation(double[][] matrix)`
Constructs a 2D transformation using the given matrix. Affine transformations can be applied to 2D coordinates. A 2 by 3 matrix sets the rotation and shear. A null matrix sets the transformation to the identity transformation.

Parameters:
`matrix` - double[][]

### Matrix2DTransformation

`public Matrix2DTransformation(java.awt.geom.AffineTransform transform)`
Constructor Matrix2DTransformation

Parameters:
`transform` -
Method Detail

### rotation

`public static Matrix2DTransformation rotation(double theta)`
Creates a 2D transformation representing a rotation about the origin by the given angle.

Parameters:
`theta` - double
Returns:
Matrix2DTransformation

### rotation

```public static Matrix2DTransformation rotation(double theta,
double anchorx,
double anchory)```
Creates a 2D transformation representing a rotation about the origin by the given angle around the given axis.

Parameters:
`theta` - double
`anchorx` - double
`anchory` - double
Returns:
Matrix2DTransformation

### getTotalTransform

`public java.awt.geom.AffineTransform getTotalTransform()`

### clone

`public java.lang.Object clone()`
Provides a copy of this transformation.

Specified by:
`clone` in interface `Transformation`
Overrides:
`clone` in class `java.lang.Object`

### getFlatMatrix

`public final double[] getFlatMatrix(double[] mat)`
Gets the direct homogeneous affine transformation flattened into a 1-d arrray. If the mat parameter is null a double[6] array is created; otherwise the given array is used.

Specified by:
`getFlatMatrix` in interface `MatrixTransformation`
Parameters:
`mat` - double[] optional matrix
Returns:
double[] the matrix

### createAlignmentTransformation

```public static Matrix2DTransformation createAlignmentTransformation(double[] v1,
double[] v2)```
Instantiates a rotation that aligns the first vector with the second vector.

Parameters:
`v1` - double[]
`v2` - double[]
Returns:
Matrix2DTransformation

### setOrigin

```public void setOrigin(double ox,
double oy)```
Sets the origin for this rotation.

Parameters:
`ox` - double
`oy` - double

### setOrigin

`public double[] setOrigin(double[] origin)`
Sets the origin for this rotation.

Parameters:
`origin` - double[] the new origin
Returns:
double[]

### multiply

`public final void multiply(Matrix2DTransformation trans)`
Multiplies (concatenates) this transformation matrix with the given transformation.

Parameters:
`trans` - Matrix2DTransformation

### multiply

`public final void multiply(double[][] mat)`
Multiplies this rotation matrix by the given matrix.

Parameters:
`mat` - double[][]

### direct

`public double[] direct(double[] point)`
Transforms the given point+.

Specified by:
`direct` in interface `Transformation`
Parameters:
`point` - the coordinates to be transformed
Returns:
double[] the transformed vector (i.e. point)

### inverse

```public double[] inverse(double[] point)
throws java.lang.UnsupportedOperationException```
Transforms the given point using the inverse transformation (if it exists). If the transformation is not invertible, then a call to this method must throw a UnsupportedOperationException exception.

Specified by:
`inverse` in interface `Transformation`
Parameters:
`point` - the coordinates to be transformed
Returns:
double[] the transformed vector (i.e. point)
Throws:
`java.lang.UnsupportedOperationException` - If the transformation is not invertible

`public static XML.ObjectLoader getLoader()`