Package org.opensourcephysics.numerics
Class Matrix2DTransformation
java.lang.Object
org.opensourcephysics.numerics.Matrix2DTransformation
- All Implemented Interfaces:
Cloneable,MatrixTransformation,Transformation
Matrix2DTransformation implements 2D affine transformations
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class -
Constructor Summary
ConstructorsConstructorDescriptionMatrix2DTransformation(double[][] matrix) Constructs a 2D transformation using the given matrix.Matrix2DTransformation(AffineTransform transform) Constructor Matrix2DTransformation -
Method Summary
Modifier and TypeMethodDescriptionclone()Provides a copy of this transformation.static Matrix2DTransformationcreateAlignmentTransformation(double[] v1, double[] v2) Instantiates a rotation that aligns the first vector with the second vector.double[]direct(double[] point) Transforms the given point+.final double[]getFlatMatrix(double[] mat) Gets the direct homogeneous affine transformation flattened into a 1-d arrray.static XML.ObjectLoaderdouble[]inverse(double[] point) Transforms the given point using the inverse transformation (if it exists).final voidmultiply(double[][] mat) Multiplies this rotation matrix by the given matrix.final voidmultiply(Matrix2DTransformation trans) Multiplies (concatenates) this transformation matrix with the given transformation.static Matrix2DTransformationrotation(double theta) Creates a 2D transformation representing a rotation about the origin by the given angle.static Matrix2DTransformationrotation(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.voidsetOrigin(double ox, double oy) Sets the origin for this rotation.
-
Constructor Details
-
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
Constructor Matrix2DTransformation- Parameters:
transform-
-
-
Method Details
-
rotation
Creates a 2D transformation representing a rotation about the origin by the given angle.- Parameters:
theta- double- Returns:
- Matrix2DTransformation
-
rotation
Creates a 2D transformation representing a rotation about the origin by the given angle around the given axis.- Parameters:
theta- doubleanchorx- doubleanchory- double- Returns:
- Matrix2DTransformation
-
getTotalTransform
-
clone
Provides a copy of this transformation.- Specified by:
clonein interfaceTransformation- Overrides:
clonein classObject
-
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:
getFlatMatrixin interfaceMatrixTransformation- Parameters:
mat- double[] optional matrix- Returns:
- double[] the matrix
-
createAlignmentTransformation
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- doubleoy- double
-
setOrigin
public double[] setOrigin(double[] origin) Sets the origin for this rotation.- Parameters:
origin- double[] the new origin- Returns:
- double[]
-
multiply
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:
directin interfaceTransformation- Parameters:
point- the coordinates to be transformed- Returns:
- double[] the transformed vector (i.e. point)
-
inverse
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:
inversein interfaceTransformation- Parameters:
point- the coordinates to be transformed- Returns:
- double[] the transformed vector (i.e. point)
- Throws:
UnsupportedOperationException- If the transformation is not invertible
-
getLoader
-