Class Matrix2D

java.lang.Object
  extended by Matrix2D

public class Matrix2D
extends java.lang.Object

This Matrix2D class provides a base for exploring two-dimensional transformations. Its only instance field, matrix, is a 3×3 array of double.

Version:
1.1
Author:
C. D'Arcy

Constructor Summary
Matrix2D()
          construct the ZERO matrix (all elements are 0)
Matrix2D(double[] e)
          constructs a Matrix2D object from the given 3n-element array of double (row major).
Matrix2D(double[][] matrix)
          constructs a Matrix2D object from the elements of the given 3×n array of double.
Matrix2D(double m00, double m01, double m02, double m10, double m11, double m12, double m20, double m21, double m22)
          constructs a Matrix2D object from the 9 doubles.
Matrix2D(Matrix2D other)
          Constructs a Matrix2D object using the elements of the Matrix2D parameter
 
Method Summary
 Matrix2D add(Matrix2D other)
          Constructs and returns a new Matrix2D object consisting of the sum of the elements in the same corresponding position
 double[][] getElements()
          Accessor method used to retrieve the elements of the Matrix2D object
 Matrix2D mul(double[][] other)
          Constructs and returns a new Matrix2D object consisting of the matrix product
 Matrix2D mul(Matrix2D other)
          Constructs and returns a new Matrix2D object consisting of the matrix product
 void setElements(double[][] e)
          Assigns new values to the Matrix2D object using the elements of the array parameter
 Matrix2D sub(Matrix2D other)
          Constructs and returns a new Matrix2D object consisting of the difference of the elements in the same corresponding position
 java.lang.String toString()
          Returns a beautiful, 2-dimensional, tab-delimited String rendering an image of the Matrix2D object
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Matrix2D

public Matrix2D()
construct the ZERO matrix (all elements are 0)


Matrix2D

public Matrix2D(double[][] matrix)
constructs a Matrix2D object from the elements of the given 3×n array of double.

Parameters:
matrix - The 3×3 array of double.

Matrix2D

public Matrix2D(double[] e)
constructs a Matrix2D object from the given 3n-element array of double (row major).

Parameters:
e - The 9-element array of double.

Matrix2D

public Matrix2D(double m00,
                double m01,
                double m02,
                double m10,
                double m11,
                double m12,
                double m20,
                double m21,
                double m22)
constructs a Matrix2D object from the 9 doubles. (row major)

Parameters:
m00 - m00.
m01 - m01.
m02 - m02.
m10 - m10.
m11 - m11.
m12 - m12.
m20 - m20.
m21 - m21.
m22 - m22.

Matrix2D

public Matrix2D(Matrix2D other)
Constructs a Matrix2D object using the elements of the Matrix2D parameter

Parameters:
other - The Matrix2D object to be cloned.
Method Detail

setElements

public void setElements(double[][] e)
Assigns new values to the Matrix2D object using the elements of the array parameter

Parameters:
e - The new set of elements

getElements

public double[][] getElements()
Accessor method used to retrieve the elements of the Matrix2D object

Returns:
The elements in 3×3 array of doubles

add

public Matrix2D add(Matrix2D other)
Constructs and returns a new Matrix2D object consisting of the sum of the elements in the same corresponding position

Parameters:
other - the addend
Returns:
the Matrix2D object representing the sum of addend and the augend

sub

public Matrix2D sub(Matrix2D other)
Constructs and returns a new Matrix2D object consisting of the difference of the elements in the same corresponding position

Parameters:
other - the subtrahend
Returns:
the Matrix2D object representing the difference of minuend and the subtrahend

mul

public Matrix2D mul(Matrix2D other)
Constructs and returns a new Matrix2D object consisting of the matrix product

Parameters:
other - the multiplier
Returns:
the Matrix2D object representing the product of multiplicand and the multiplier

mul

public Matrix2D mul(double[][] other)
Constructs and returns a new Matrix2D object consisting of the matrix product

Parameters:
other - the multiplier
Returns:
the Matrix2D object representing the product of multiplicand and the multiplier

toString

public java.lang.String toString()
Returns a beautiful, 2-dimensional, tab-delimited String rendering an image of the Matrix2D object

Overrides:
toString in class java.lang.Object
Returns:
The String representation of the matrix