mr3d.lang
Class MatrixFactory

java.lang.Object
  extended bymr3d.lang.MatrixFactory

public abstract class MatrixFactory
extends java.lang.Object

The class MatrixFactory gives you several functions to create specialized matrices such as unit, rotation or translation matrices.

Since:
MR3Dv1.0
Version:
10-2004
Author:
Manuel Ruelke

Constructor Summary
MatrixFactory()
           
 
Method Summary
static Matrix createMatrix(int type)
          Creates a matrix of the specified type.
static Matrix createRotMatrix(int xangle, int yangle, int zangle)
          Creates a rotation matrix.
static Matrix createScaleMatrix(int x, int y, int z)
          Creates a scalation matrix.
static Matrix createTransMatrix(int x, int y, int z)
          Creates a 3D-translation matrix.
protected static int toLinear(int line, int column)
          Transforms two-dimensional matrix coordinates into linear coordinates.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MatrixFactory

public MatrixFactory()
Method Detail

createMatrix

public static Matrix createMatrix(int type)
Creates a matrix of the specified type. All valid types are defined as constants in the class Matrix. If a matrix type is called that is not valid an error message will be displayed on the console.

Parameters:
type - type constant of matrix
Returns:
a matrix of the specified type
See Also:
Matrix.TYPE_ZERO, Matrix.TYPE_UNIT

createRotMatrix

public static Matrix createRotMatrix(int xangle,
                                     int yangle,
                                     int zangle)
Creates a rotation matrix. This matrix can be used to do rotations about the axes of the coordinate system according to the given parameters.

If you multiply a 3D vector, which represents the coordinates of a 3D point with this matrix the point will be rotated about all coordinate axes for the given angle parameters. The following sequence will be used:

(1) rotation about the x-axis
(2) rotation about the y-axis
(3) rotation about the z-axis

The method parameter are angle values. Those values are defined as real angle value * 10. A 3D-point that is rotated by using this matrix will have coordinates 32.768 times greater than its actual value. This results from the scalation of the sinus funtion.

Parameters:
xangle - angle value * 10 to rotate about x-axis
yangle - angle value * 10 to rotate about y-axis
zangle - angle value * 10 to rotate about z-axis
Returns:
a rotation matrix
See Also:
Matrix, MathME.sin(int), MathME.cos(int)

createScaleMatrix

public static Matrix createScaleMatrix(int x,
                                       int y,
                                       int z)
Creates a scalation matrix. This matrix can be used to scale 3D objects. The scalation will modify the coordinates according to the given parameters.

Parameters:
x - value of scalation in direction of the x-axis
y - value of scalation in direction of the y-axis
z - value of scalation in direction of the z-axis
Returns:
a scalation matrix
See Also:
Matrix

createTransMatrix

public static Matrix createTransMatrix(int x,
                                       int y,
                                       int z)
Creates a 3D-translation matrix. This matrix can be used to move a 3D point in the virtual 3D world. The translation will modify the coordinates according to the given parameters.

If a 3D vector, that represents the coordinates of a 3D point, is multiplied with this translation matrix the point will move through its virtual world for the values given as parameters.

Parameters:
x - value of movement in direction of the x-axis
y - value of movement in direction of the y-axis
z - value of movement in direction of the z-axis
Returns:
a translation matrix
See Also:
Matrix

toLinear

protected static int toLinear(int line,
                              int column)
Transforms two-dimensional matrix coordinates into linear coordinates.

Parameters:
line - line index
column - column ndex
Returns:
the linear coordinate of the element at the specified line and column index.