ImageScience 3.0.0

imagescience.transform
Class Transform

java.lang.Object
  extended by imagescience.transform.Transform

public class Transform
extends java.lang.Object

Represents a 3D affine transformation matrix. The matrix has the following form:

     [ axx axy axz axt ]
     [ ayx ayy ayz ayt ]
     [ azx azy azz azt ]
     [  0   0   0   1  ]
Methods are provided for easy manipulation of the matrix.


Field Summary
 double axt
          The matrix element axt.
 double axx
          The matrix element axx.
 double axy
          The matrix element axy.
 double axz
          The matrix element axz.
 double ayt
          The matrix element ayt.
 double ayx
          The matrix element ayx.
 double ayy
          The matrix element ayy.
 double ayz
          The matrix element ayz.
 double azt
          The matrix element azt.
 double azx
          The matrix element azx.
 double azy
          The matrix element azy.
 double azz
          The matrix element azz.
 
Constructor Summary
Transform()
          Default constructor.
Transform(double[][] array)
          Array constructor.
Transform(double axx, double axy, double axz, double axt, double ayx, double ayy, double ayz, double ayt, double azx, double azy, double azz, double azt)
          Element constructor.
Transform(Transform transform)
          Copy constructor.
 
Method Summary
 double determinant()
          Returns the determinant of the transformation matrix.
 Transform duplicate()
          Duplicates the transform.
 boolean equals(Transform transform)
          Indicates whether the transform is equal to the given transform.
 double[][] get()
          Returns the transformation matrix as a 4 x 4 double array.
 double get(int row, int column)
          Returns the element at the given row and column of the transformation matrix.
 boolean identity()
          Indicates whether the transformation matrix is equal to the identity matrix.
 void invert()
          Inverts the transformation matrix.
 void reset()
          Resets the transformation matrix to the identity matrix.
 void rotate(double angle, int axis)
          Rotates the transformation matrix.
 void scale(double factor, int axis)
          Scales the transformation matrix.
 void set(double[][] array)
          Sets the elements of the transformation matrix to those of the given array.
 void set(double axx, double axy, double axz, double axt, double ayx, double ayy, double ayz, double ayt, double azx, double azy, double azz, double azt)
          Sets the elements of the transformation matrix to the given values.
 void set(int row, int column, double value)
          Sets the element at the given row and column of the transformation matrix to the given value.
 void set(Transform transform)
          Sets the elements of the transformation matrix to those of the given transform.
 void shear(double factor, int axis, int drive)
          Shears the transformation matrix.
 java.lang.String string()
          Returns a string representation of the transformation matrix.
 java.lang.String string(java.lang.String prefix, java.lang.String delimit, java.lang.String postfix)
          Returns a formatted string representation of the transformation matrix.
 void transform(Point point)
          Transforms the given point.
 void transform(Transform transform)
          Transforms the transformation matrix.
 void translate(double distance, int axis)
          Translates the transformation matrix.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

axx

public double axx
The matrix element axx.


axy

public double axy
The matrix element axy.


axz

public double axz
The matrix element axz.


axt

public double axt
The matrix element axt.


ayx

public double ayx
The matrix element ayx.


ayy

public double ayy
The matrix element ayy.


ayz

public double ayz
The matrix element ayz.


ayt

public double ayt
The matrix element ayt.


azx

public double azx
The matrix element azx.


azy

public double azy
The matrix element azy.


azz

public double azz
The matrix element azz.


azt

public double azt
The matrix element azt.

Constructor Detail

Transform

public Transform()
Default constructor. Sets the transformation matrix to the identity matrix.


Transform

public Transform(Transform transform)
Copy constructor. Sets the elements of the transformation matrix to those of the given transform.

Throws:
java.lang.NullPointerException - If transform is null.

Transform

public Transform(double[][] array)
Array constructor. Sets the elements of the transformation matrix to those of the given array.

Parameters:
array - The array containing the transformation matrix. Must be a 4 x 4 array with the first index corresponding to the rows and second index corresponding to the columns of the matrix.
Throws:
java.lang.IllegalArgumentException - If array is not a 4 x 4 array.
java.lang.NullPointerException - If array is null.

Transform

public Transform(double axx,
                 double axy,
                 double axz,
                 double axt,
                 double ayx,
                 double ayy,
                 double ayz,
                 double ayt,
                 double azx,
                 double azy,
                 double azz,
                 double azt)
Element constructor. Sets the elements of the transformation matrix to the given values.

Method Detail

duplicate

public Transform duplicate()
Duplicates the transform.

Returns:
A new Transform object that is an exact copy of this object. All information is copied and no memory is shared between this and the returned object.

equals

public boolean equals(Transform transform)
Indicates whether the transform is equal to the given transform.

Parameters:
transform - The transform to compare this transform with.
Returns:
Value true if transform is not null and its matrix is equal to the matrix of this object, or false if this is not the case.

identity

public boolean identity()
Indicates whether the transformation matrix is equal to the identity matrix.

Returns:
Value true if the transformation matrix is equal to the identity matrix, or false if this is not the case.

reset

public void reset()
Resets the transformation matrix to the identity matrix.


determinant

public double determinant()
Returns the determinant of the transformation matrix.

Returns:
The determinant of the transformation matrix.

invert

public void invert()
Inverts the transformation matrix.

Throws:
java.lang.IllegalStateException - If the transformation matrix is non-invertible.

transform

public void transform(Transform transform)
Transforms the transformation matrix.

Parameters:
transform - The transform to be applied.
Throws:
java.lang.NullPointerException - If transform is null.

transform

public void transform(Point point)
Transforms the given point.

Parameters:
point - The point to be transformed. The point is treated as a 3D point. That is, only its x, y, z coordinates are used, which are replaced by their transformed coordinates.
Throws:
java.lang.NullPointerException - If point is null.

rotate

public void rotate(double angle,
                   int axis)
Rotates the transformation matrix.

Parameters:
angle - The rotation angle in degrees.
axis - The rotation axis. Must be one of Axes.X, Axes.Y, Axes.Z.
Throws:
java.lang.IllegalArgumentException - If axis is invalid.

scale

public void scale(double factor,
                  int axis)
Scales the transformation matrix.

Parameters:
factor - The scaling factor.
axis - The scaling axis. Must be one of Axes.X, Axes.Y, Axes.Z.
Throws:
java.lang.IllegalArgumentException - If axis is invalid.

shear

public void shear(double factor,
                  int axis,
                  int drive)
Shears the transformation matrix.

Parameters:
factor - The shearing factor.
axis - The shearing axis. Must be one of Axes.X, Axes.Y, Axes.Z.
drive - The driving axis. Must be one of Axes.X, Axes.Y, Axes.Z.
Throws:
java.lang.IllegalArgumentException - If any of axis or drive is invalid.

translate

public void translate(double distance,
                      int axis)
Translates the transformation matrix.

Parameters:
distance - The translation distance.
axis - The translation axis. Must be one of Axes.X, Axes.Y, Axes.Z.
Throws:
java.lang.IllegalArgumentException - If axis is invalid.

set

public void set(Transform transform)
Sets the elements of the transformation matrix to those of the given transform.

Throws:
java.lang.NullPointerException - If transform is null.

set

public void set(double axx,
                double axy,
                double axz,
                double axt,
                double ayx,
                double ayy,
                double ayz,
                double ayt,
                double azx,
                double azy,
                double azz,
                double azt)
Sets the elements of the transformation matrix to the given values.


set

public void set(double[][] array)
Sets the elements of the transformation matrix to those of the given array.

Parameters:
array - The array containing the transformation matrix. Must be a 4 x 4 array with the first index corresponding to the rows and second index corresponding to the columns of the matrix.
Throws:
java.lang.IllegalArgumentException - If array is not a 4 x 4 array.
java.lang.NullPointerException - If array is null.

set

public void set(int row,
                int column,
                double value)
Sets the element at the given row and column of the transformation matrix to the given value.

Parameters:
row - The row index. Must be 0, 1, or 2 (row 3 is fixed).
column - The column index. Must be 0, 1, 2, or 3.
value - The value.
Throws:
java.lang.IllegalArgumentException - If row or column is out of bounds.

get

public double[][] get()
Returns the transformation matrix as a 4 x 4 double array.


get

public double get(int row,
                  int column)
Returns the element at the given row and column of the transformation matrix.

Parameters:
row - The row index. Must be 0, 1, 2, or 3.
column - The column index. Must be 0, 1, 2, or 3.
Throws:
java.lang.IllegalArgumentException - If row or column is out of bounds.

string

public java.lang.String string()
Returns a string representation of the transformation matrix.

Returns:
A new String object containing a string representation of the transformation matrix.

string

public java.lang.String string(java.lang.String prefix,
                               java.lang.String delimit,
                               java.lang.String postfix)
Returns a formatted string representation of the transformation matrix.

Parameters:
prefix - The string put at the beginning of each matrix row.
delimit - The string put as delimiter between the matrix row elements.
postfix - The string put at the end of each matrix row.
Returns:
A new String object containing a formatted string representation of the transformation matrix.

ImageScience 3.0.0

Copyright (C) Erik Meijering. Permission to use this software and corresponding documentation for educational, research, and not-for-profit purposes, without a fee and without a signed licensing agreement, is granted, subject to the following terms and conditions.

IT IS NOT ALLOWED TO REDISTRIBUTE, SELL, OR LEASE THIS SOFTWARE, OR DERIVATIVE WORKS THEREOF, WITHOUT PERMISSION IN WRITING FROM THE COPYRIGHT HOLDER. THE COPYRIGHT HOLDER IS FREE TO MAKE VERSIONS OF THE SOFTWARE AVAILABLE FOR A FEE OR COMMERCIALLY ONLY.

IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OF ANY KIND WHATSOEVER, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.

THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE EXPRESS OR IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE AND CORRESPONDING DOCUMENTATION IS PROVIDED "AS IS". THE COPYRIGHT HOLDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.