public class AffineTransformation
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private int |
dim
the dimensionality of the transformation
|
private double[][] |
inv
the inverse transformation
|
private double[][] |
trans
The transformation matrix of dim+1 x dim+1 for homogeneous coordinates
|
Constructor and Description |
---|
AffineTransformation(int dim)
Constructor for an identity transformation.
|
AffineTransformation(int dim,
double[][] trans,
double[][] inv)
Trivial constructor with all fields, mostly for cloning
|
Modifier and Type | Method and Description |
---|---|
void |
addAxisReflection(int axis)
Add a reflection along the given axis.
|
void |
addMatrix(double[][] m)
Add a matrix operation to the matrix.
|
void |
addRotation(int axis1,
int axis2,
double angle)
Convenience function to apply a rotation in 2 dimensions.
|
void |
addScaling(double scale)
Simple linear (symmetric) scaling.
|
void |
addTranslation(double[] v)
Add a translation operation to the matrix
|
double[] |
apply(double[] v)
Apply the transformation onto a vector
|
double[] |
applyInverse(double[] v)
Apply the inverse transformation onto a vector
|
double[] |
applyRelative(double[] v)
Apply the transformation onto a vector
|
double[] |
applyRelativeInverse(double[] v)
Apply the inverse transformation onto a vector
|
int |
getDimensionality()
Query dimensionality of the transformation.
|
double[][] |
getInverse()
Get a the inverse matrix
|
double[][] |
getTransformation()
Get the transformation matrix
|
double[] |
homogeneRelativeVector(double[] v)
Transform a relative vector into homogeneous coordinates.
|
double[] |
homogeneVector(double[] v)
Transform an absolute vector into homogeneous coordinates.
|
static AffineTransformation |
reorderAxesTransformation(int dim,
int... axes)
Generate a transformation that reorders axes in the given way.
|
double[] |
unhomogeneRelativeVector(double[] v)
Project an homogeneous vector back into the original space.
|
double[] |
unhomogeneVector(double[] v)
Project an homogeneous vector back into the original space.
|
private void |
updateInverse()
Compute the inverse transformation matrix
|
private final int dim
private double[][] trans
private double[][] inv
public AffineTransformation(int dim)
dim
- dimensionalitypublic AffineTransformation(int dim, double[][] trans, double[][] inv)
dim
- dimensionalitytrans
- transformation matrix (will NOT be copied!)inv
- inverse matrix (will NOT be copied!)public static AffineTransformation reorderAxesTransformation(int dim, int... axes)
dim
- Dimensionality of vector space (resulting Matrix will be dim+1 x
dim+1)axes
- (Partial) list of axespublic int getDimensionality()
public void addTranslation(double[] v)
v
- translation vectorpublic void addMatrix(double[][] m)
m
- matrix (should be invertible)public void addRotation(int axis1, int axis2, double angle)
axis1
- first dimensionaxis2
- second dimensionangle
- rotation angle in radians.public void addAxisReflection(int axis)
axis
- Axis number to do the reflection at.public void addScaling(double scale)
scale
- Scaling factorpublic double[][] getTransformation()
public double[][] getInverse()
private void updateInverse()
public double[] homogeneVector(double[] v)
v
- initial vectorpublic double[] homogeneRelativeVector(double[] v)
v
- initial vectorpublic double[] unhomogeneVector(double[] v)
v
- Matrix of 1 x dim+1 containing the homogeneous vectorpublic double[] unhomogeneRelativeVector(double[] v)
v
- Matrix of 1 x dim+1 containing the homogeneous vectorpublic double[] apply(double[] v)
v
- vector of dimensionality dimpublic double[] applyInverse(double[] v)
v
- vector of dimensionality dimpublic double[] applyRelative(double[] v)
v
- vector of dimensionality dimpublic double[] applyRelativeInverse(double[] v)
v
- vector of dimensionality dimCopyright © 2019 ELKI Development Team. License information.