org.grinvin.gred.transformations

Class AffineTransformation

Implemented Interfaces:
Transformation

public class AffineTransformation
extends AbstractTransformation

Affine transformation from n-space to 2-space. Such a transformation is represented by a matrix
    [ a00 a01 a02 ... b0 ]
    [ a10 a11 a12 ... b1 ]
 
and transforms source coordinates (c0,c1,...) to destination coordinates (x,y) as follows:
    x = a00 c0 + a01 c1 + a02 c2 + ... + b0
    y = a10 c0 + a11 c1 + a12 c2 + ... + b1
 

Constructor Summary

AffineTransformation()
Create an identity transform for two-dimensional space.
AffineTransformation(double[][] matrix)
Create a new affine transformation with given transformation matrix.

Method Summary

@Override
boolean isInvertible()
Is this transformation invertible?
@Override
double[] transform(double[] src, double[] dest)
@Override
int getDimension()
void
moveOrigin(double tx, double ty)
Concatenate a translation (in destination space) with this transformation.
void
rotate(double angle)
Perform a rotation over the given angle around the origin in destination space.
@Override
void inverseTransform(double x, double y, double[] dest)
Perform an inverse transformation from destination space back to source space.
void
zoom(double factor)
Zoom by the given factor in destination space.

Methods inherited from class org.grinvin.gred.transformations.AbstractTransformation

getDimension, inverseTransform, isInvertible, transform

Methods inherited from class org.grinvin.gred.transformations.TransformationSupport

addTransformationListener, fireTransformationChanged, removeTransformationListener

Constructor Details

AffineTransformation

public AffineTransformation()
Create an identity transform for two-dimensional space.

AffineTransformation

public AffineTransformation(double[][] matrix)
Create a new affine transformation with given transformation matrix.
Parameters:
matrix - transformation matrix

Method Details

boolean isInvertible

public @Override boolean isInvertible()
Is this transformation invertible?
Returns:
true if invertible, false if not

double[] transform

public @Override double[] transform(double[] src,
                                    double[] dest)

int getDimension

public @Override int getDimension()

moveOrigin

public void moveOrigin(double tx,
                       double ty)
Concatenate a translation (in destination space) with this transformation.
Parameters:
tx - Delta x
ty - Delta y

rotate

public void rotate(double angle)
Perform a rotation over the given angle around the origin in destination space.

void inverseTransform

public @Override void inverseTransform(double x,
                                       double y,
                                       double[] dest)
            throws IllegalStateException
Perform an inverse transformation from destination space back to source space.

Parameters:
x -
y -
dest -

zoom

public void zoom(double factor)
Zoom by the given factor in destination space.