Class com.oroinc.math.geometry.SquareMatrix
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.oroinc.math.geometry.SquareMatrix

java.lang.Object
   |
   +----com.oroinc.math.geometry.SquareMatrix

public final class SquareMatrix
extends Object
implements Cloneable
The SquareMatrix class represents a matrix with equal numbers of rows and columns. It is used to perform transformations on points and vectors.

Copyright © 1996, 1997 Original Reusable Objects, Inc. All rights reserved.

Author:
Daniel F. Savarese

Constructor Index

 o SquareMatrix(int)
Creates a n x n matrix with all cells initialized to zero.
 o SquareMatrix(SquareMatrix)
Creates a copy of a matrix.

Method Index

 o assign(SquareMatrix)
Assigns the parameter matrix to the calling matrix.
 o clone()
Returns a deep copy of the Tuple.
 o determinant()
Calculates the determinant of the matrix and returns its value.
 o element(int, int)
Returns the element at the indicated location in the matrix.
 o identity()
Turns the matrix into the identity matrix.
 o invert()
Inverts the matrix.
 o invert(SquareMatrix)
Sets the parameter matrix to the inverse of the calling matrix.
 o multiply(float)
Multiplies the matrix by a scalar and returns the resulting SquareMatrix.
 o multiply(SquareMatrix)
Multiplies the matrix by another matrix and returns the resulting SquareMatrix.
 o multiply(Tuple)
Multiplies the matrix by a Tuple and returns the resulting tuple.
 o multiplyBy(float)
This method is the equivalent of the *= operator.
 o setElement(int, int, float)
Assigns a value to the Tuple element at the indicated row and column.
 o toString()
Returns a string representation of the matrix.
 o transpose()
Transposes the matrix.
 o transpose(SquareMatrix)
Sets the parameter matrix to the transpose of the calling matrix.
 o zero()
Sets all the elements of the matrix to zero.

Constructors

 o SquareMatrix
  public SquareMatrix(SquareMatrix matrix)
Creates a copy of a matrix.

Parameters:
matrix - The matrix to copy.
 o SquareMatrix
  public SquareMatrix(int dimension)
Creates a n x n matrix with all cells initialized to zero.

Parameters:
dimension - The number of rows and columns in the matrix.

Methods

 o clone
  public Object clone()
Returns a deep copy of the Tuple. Essentially just returns
new SquareMatrix(this);
SquareMatrix implements the Cloneable interface principally as a convenience.

Returns:
A deep copy of the SquareMatrix.
Overrides:
clone in class Object
 o assign
  public void assign(SquareMatrix matrix)
Assigns the parameter matrix to the calling matrix. Assumes matrices are of equal dimension.

Parameters:
matrix - The value to assign to the caller.
 o multiplyBy
  public void multiplyBy(float scalar)
This method is the equivalent of the *= operator. It multiplies the SquareMatrix by the argument.

Parameters:
scalar - The value by which to mulitply the matrix.
 o multiply
  public SquareMatrix multiply(float scalar)
Multiplies the matrix by a scalar and returns the resulting SquareMatrix.

Parameters:
scalar - The value by which to multiply the matrix.
Returns:
The result of the multiplication.
 o multiply
  public SquareMatrix multiply(SquareMatrix matrix)
Multiplies the matrix by another matrix and returns the resulting SquareMatrix.

Parameters:
tuple - The value by which to multiply the matrix.
Returns:
The result of the multiplication.
 o multiply
  public Tuple multiply(Tuple tuple)
Multiplies the matrix by a Tuple and returns the resulting tuple.

Parameters:
tuple - The value by which to multiply the matrix.
Returns:
The result of the multiplication.
 o element
  public float element(int row,
                       int column)
Returns the element at the indicated location in the matrix. No bounds checking is done.

Parameters:
column - The column of the matrix element to return.
Throws: ArrayIndexOutOfBoundsException
If the row and column do not occur within the matrix.
 o setElement
  public void setElement(int row,
                         int column,
                         float scalar)
Assigns a value to the Tuple element at the indicated row and column.

Parameters:
row - The row of the element to change.
column - The row of the element to change.
scalar - The new value to assign.
 o determinant
  public float determinant()
Calculates the determinant of the matrix and returns its value.

Returns:
The determinant of the matrix.
 o zero
  public void zero()
Sets all the elements of the matrix to zero.
 o identity
  public void identity()
Turns the matrix into the identity matrix. That is, all of the matrix cells become equal to zero, except for the diagonal, which becomes equal to 1.
 o invert
  public void invert()
Inverts the matrix.
 o invert
  public void invert(SquareMatrix matrix)
Sets the parameter matrix to the inverse of the calling matrix. Assumes matrices are of equal dimension.

Parameters:
matrix - This parameter is set to the inverse of the matrix. The calling matrix is left unchanged.
 o transpose
  public void transpose()
Transposes the matrix.
 o transpose
  public void transpose(SquareMatrix matrix)
Sets the parameter matrix to the transpose of the calling matrix. Assumes matrices are of equal dimension.

Parameters:
matrix - This parameter is set to the transpose of the matrix. The calling matrix is left unchanged.
 o toString
  public final String toString()
Returns a string representation of the matrix.

Returns:
A string representation of the matrix.
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index