Back to index

wims  3.65+svn20090927
Public Member Functions | Package Functions | Package Attributes | Static Package Attributes
Matrix3D Class Reference

A fairly conventional 3D matrix object that can transform sets of 3D points and perform a variety of manipulations on the transform. More...

List of all members.

Public Member Functions

String toString ()
String toString ()

Package Functions

 Matrix3D ()
 Create a new unit matrix.
void scale (float f)
 Scale by f in all dimensions.
void scale (float xf, float yf, float zf)
 Scale along each axis independently.
void translate (float x, float y, float z)
 Translate the origin.
void yrot (double theta)
 rotate theta degrees about the y axis
void xrot (double theta)
 rotate theta degrees about the x axis
void zrot (double theta)
 rotate theta degrees about the z axis
void mult (Matrix3D rhs)
 Multiply this matrix by a second: M = M*R.
void unit ()
 Reinitialize to the unit matrix.
void transform (float v[], int tv[], int nvert)
 Transform nvert points from v into tv.
 Matrix3D ()
 Create a new unit matrix.
void scale (float f)
 Scale by f in all dimensions.
void scale (float xf, float yf, float zf)
 Scale along each axis independently.
void translate (float x, float y, float z)
 Translate the origin.
void yrot (double theta)
 rotate theta degrees about the y axis
void xrot (double theta)
 rotate theta degrees about the x axis
void zrot (double theta)
 rotate theta degrees about the z axis
void mult (Matrix3D rhs)
 Multiply this matrix by a second: M = M*R.
void unit ()
 Reinitialize to the unit matrix.
void transform (float v[], int tv[], int nvert)
 Transform nvert points from v into tv.

Package Attributes

float xx
float xy
float xz
float xo
float yx
float yy
float yz
float yo
float zx
float zy
float zz
float zo

Static Package Attributes

static final double pi = 3.14159265

Detailed Description

A fairly conventional 3D matrix object that can transform sets of 3D points and perform a variety of manipulations on the transform.

Definition at line 33 of file Matrix3D.java.


Constructor & Destructor Documentation

Matrix3D.Matrix3D ( ) [inline, package]

Create a new unit matrix.

Definition at line 39 of file Matrix3D.java.

                {
       xx = 1.0f;
       yy = 1.0f;
       zz = 1.0f;
    }
Matrix3D.Matrix3D ( ) [inline, package]

Create a new unit matrix.

Definition at line 14 of file Matrix3D.java.

                {
       xx = 1.0f;
       yy = 1.0f;
       zz = 1.0f;
    }

Member Function Documentation

void Matrix3D.mult ( Matrix3D  rhs) [inline, package]

Multiply this matrix by a second: M = M*R.

Definition at line 131 of file Matrix3D.java.

                            {
       float lxx = xx * rhs.xx + yx * rhs.xy + zx * rhs.xz;
       float lxy = xy * rhs.xx + yy * rhs.xy + zy * rhs.xz;
       float lxz = xz * rhs.xx + yz * rhs.xy + zz * rhs.xz;
       float lxo = xo * rhs.xx + yo * rhs.xy + zo * rhs.xz + rhs.xo;

       float lyx = xx * rhs.yx + yx * rhs.yy + zx * rhs.yz;
       float lyy = xy * rhs.yx + yy * rhs.yy + zy * rhs.yz;
       float lyz = xz * rhs.yx + yz * rhs.yy + zz * rhs.yz;
       float lyo = xo * rhs.yx + yo * rhs.yy + zo * rhs.yz + rhs.yo;

       float lzx = xx * rhs.zx + yx * rhs.zy + zx * rhs.zz;
       float lzy = xy * rhs.zx + yy * rhs.zy + zy * rhs.zz;
       float lzz = xz * rhs.zx + yz * rhs.zy + zz * rhs.zz;
       float lzo = xo * rhs.zx + yo * rhs.zy + zo * rhs.zz + rhs.zo;

       xx = lxx;
       xy = lxy;
       xz = lxz;
       xo = lxo;

       yx = lyx;
       yy = lyy;
       yz = lyz;
       yo = lyo;

       zx = lzx;
       zy = lzy;
       zz = lzz;
       zo = lzo;
    }
void Matrix3D.mult ( Matrix3D  rhs) [inline, package]

Multiply this matrix by a second: M = M*R.

Definition at line 156 of file Matrix3D.java.

                            {
       float lxx = xx * rhs.xx + yx * rhs.xy + zx * rhs.xz;
       float lxy = xy * rhs.xx + yy * rhs.xy + zy * rhs.xz;
       float lxz = xz * rhs.xx + yz * rhs.xy + zz * rhs.xz;
       float lxo = xo * rhs.xx + yo * rhs.xy + zo * rhs.xz + rhs.xo;

       float lyx = xx * rhs.yx + yx * rhs.yy + zx * rhs.yz;
       float lyy = xy * rhs.yx + yy * rhs.yy + zy * rhs.yz;
       float lyz = xz * rhs.yx + yz * rhs.yy + zz * rhs.yz;
       float lyo = xo * rhs.yx + yo * rhs.yy + zo * rhs.yz + rhs.yo;

       float lzx = xx * rhs.zx + yx * rhs.zy + zx * rhs.zz;
       float lzy = xy * rhs.zx + yy * rhs.zy + zy * rhs.zz;
       float lzz = xz * rhs.zx + yz * rhs.zy + zz * rhs.zz;
       float lzo = xo * rhs.zx + yo * rhs.zy + zo * rhs.zz + rhs.zo;

       xx = lxx;
       xy = lxy;
       xz = lxz;
       xo = lxo;

       yx = lyx;
       yy = lyy;
       yz = lyz;
       yo = lyo;

       zx = lzx;
       zy = lzy;
       zz = lzz;
       zo = lzo;
    }

Here is the caller graph for this function:

void Matrix3D.scale ( float  f) [inline, package]

Scale by f in all dimensions.

Definition at line 20 of file Matrix3D.java.

                        {
       xx *= f;
       xy *= f;
       xz *= f;
       xo *= f;
       yx *= f;
       yy *= f;
       yz *= f;
       yo *= f;
       zx *= f;
       zy *= f;
       zz *= f;
       zo *= f;
    }
void Matrix3D.scale ( float  xf,
float  yf,
float  zf 
) [inline, package]

Scale along each axis independently.

Definition at line 35 of file Matrix3D.java.

                                             {
       xx *= xf;
       xy *= xf;
       xz *= xf;
       xo *= xf;
       yx *= yf;
       yy *= yf;
       yz *= yf;
       yo *= yf;
       zx *= zf;
       zy *= zf;
       zz *= zf;
       zo *= zf;
    }
void Matrix3D.scale ( float  f) [inline, package]

Scale by f in all dimensions.

Definition at line 45 of file Matrix3D.java.

                        {
       xx *= f;
       xy *= f;
       xz *= f;
       xo *= f;
       yx *= f;
       yy *= f;
       yz *= f;
       yo *= f;
       zx *= f;
       zy *= f;
       zz *= f;
       zo *= f;
    }

Here is the caller graph for this function:

void Matrix3D.scale ( float  xf,
float  yf,
float  zf 
) [inline, package]

Scale along each axis independently.

Definition at line 60 of file Matrix3D.java.

                                             {
       xx *= xf;
       xy *= xf;
       xz *= xf;
       xo *= xf;
       yx *= yf;
       yy *= yf;
       yz *= yf;
       yo *= yf;
       zx *= zf;
       zy *= zf;
       zz *= zf;
       zo *= zf;
    }
String Matrix3D.toString ( ) [inline]

Definition at line 195 of file Matrix3D.java.

                             {
       return ("[" + xo + "," + xx + "," + xy + "," + xz + ";"
              + yo + "," + yx + "," + yy + "," + yz + ";"
              + zo + "," + zx + "," + zy + "," + zz + "]");
    }
String Matrix3D.toString ( ) [inline]

Definition at line 220 of file Matrix3D.java.

                             {
       return ("[" + xo + "," + xx + "," + xy + "," + xz + ";"
              + yo + "," + yx + "," + yy + "," + yz + ";"
              + zo + "," + zx + "," + zy + "," + zz + "]");
    }
void Matrix3D.transform ( float  v[],
int  tv[],
int  nvert 
) [inline, package]

Transform nvert points from v into tv.

v contains the input coordinates in floating point. Three successive entries in the array constitute a point. tv ends up holding the transformed points as integers; three successive entries per point

Definition at line 182 of file Matrix3D.java.

                                                   {
       float lxx = xx, lxy = xy, lxz = xz, lxo = xo;
       float lyx = yx, lyy = yy, lyz = yz, lyo = yo;
       float lzx = zx, lzy = zy, lzz = zz, lzo = zo;
       for (int i = nvert * 3; (i -= 3) >= 0;) {
           float x = v[i];
           float y = v[i + 1];
           float z = v[i + 2];
           tv[i    ] = (int) (x * lxx + y * lxy + z * lxz + lxo);
           tv[i + 1] = (int) (x * lyx + y * lyy + z * lyz + lyo);
           tv[i + 2] = (int) (x * lzx + y * lzy + z * lzz + lzo);
       }
    }
void Matrix3D.transform ( float  v[],
int  tv[],
int  nvert 
) [inline, package]

Transform nvert points from v into tv.

v contains the input coordinates in floating point. Three successive entries in the array constitute a point. tv ends up holding the transformed points as integers; three successive entries per point

Definition at line 207 of file Matrix3D.java.

                                                   {
       float lxx = xx, lxy = xy, lxz = xz, lxo = xo;
       float lyx = yx, lyy = yy, lyz = yz, lyo = yo;
       float lzx = zx, lzy = zy, lzz = zz, lzo = zo;
       for (int i = nvert * 3; (i -= 3) >= 0;) {
           float x = v[i];
           float y = v[i + 1];
           float z = v[i + 2];
           tv[i    ] = (int) (x * lxx + y * lxy + z * lxz + lxo);
           tv[i + 1] = (int) (x * lyx + y * lyy + z * lyz + lyo);
           tv[i + 2] = (int) (x * lzx + y * lzy + z * lzz + lzo);
       }
    }

Here is the caller graph for this function:

void Matrix3D.translate ( float  x,
float  y,
float  z 
) [inline, package]

Translate the origin.

Definition at line 50 of file Matrix3D.java.

                                              {
       xo += x;
       yo += y;
       zo += z;
    }
void Matrix3D.translate ( float  x,
float  y,
float  z 
) [inline, package]

Translate the origin.

Definition at line 75 of file Matrix3D.java.

                                              {
       xo += x;
       yo += y;
       zo += z;
    }

Here is the caller graph for this function:

void Matrix3D.unit ( ) [inline, package]

Reinitialize to the unit matrix.

Definition at line 164 of file Matrix3D.java.

                {
       xo = 0;
       xx = 1;
       xy = 0;
       xz = 0;
       yo = 0;
       yx = 0;
       yy = 1;
       yz = 0;
       zo = 0;
       zx = 0;
       zy = 0;
       zz = 1;
    }
void Matrix3D.unit ( ) [inline, package]

Reinitialize to the unit matrix.

Definition at line 189 of file Matrix3D.java.

                {
       xo = 0;
       xx = 1;
       xy = 0;
       xz = 0;
       yo = 0;
       yx = 0;
       yy = 1;
       yz = 0;
       zo = 0;
       zx = 0;
       zy = 0;
       zz = 1;
    }

Here is the caller graph for this function:

void Matrix3D.xrot ( double  theta) [inline, package]

rotate theta degrees about the x axis

Definition at line 81 of file Matrix3D.java.

                            {
       theta *= (pi / 180);
       double ct = Math.cos(theta);
       double st = Math.sin(theta);

       float Nyx = (float) (yx * ct + zx * st);
       float Nyy = (float) (yy * ct + zy * st);
       float Nyz = (float) (yz * ct + zz * st);
       float Nyo = (float) (yo * ct + zo * st);

       float Nzx = (float) (zx * ct - yx * st);
       float Nzy = (float) (zy * ct - yy * st);
       float Nzz = (float) (zz * ct - yz * st);
       float Nzo = (float) (zo * ct - yo * st);

       yo = Nyo;
       yx = Nyx;
       yy = Nyy;
       yz = Nyz;
       zo = Nzo;
       zx = Nzx;
       zy = Nzy;
       zz = Nzz;
    }
void Matrix3D.xrot ( double  theta) [inline, package]

rotate theta degrees about the x axis

Definition at line 106 of file Matrix3D.java.

                            {
       theta *= (pi / 180);
       double ct = Math.cos(theta);
       double st = Math.sin(theta);

       float Nyx = (float) (yx * ct + zx * st);
       float Nyy = (float) (yy * ct + zy * st);
       float Nyz = (float) (yz * ct + zz * st);
       float Nyo = (float) (yo * ct + zo * st);

       float Nzx = (float) (zx * ct - yx * st);
       float Nzy = (float) (zy * ct - yy * st);
       float Nzz = (float) (zz * ct - yz * st);
       float Nzo = (float) (zo * ct - yo * st);

       yo = Nyo;
       yx = Nyx;
       yy = Nyy;
       yz = Nyz;
       zo = Nzo;
       zx = Nzx;
       zy = Nzy;
       zz = Nzz;
    }

Here is the caller graph for this function:

void Matrix3D.yrot ( double  theta) [inline, package]

rotate theta degrees about the y axis

Definition at line 56 of file Matrix3D.java.

                            {
       theta *= (pi / 180);
       double ct = Math.cos(theta);
       double st = Math.sin(theta);

       float Nxx = (float) (xx * ct + zx * st);
       float Nxy = (float) (xy * ct + zy * st);
       float Nxz = (float) (xz * ct + zz * st);
       float Nxo = (float) (xo * ct + zo * st);

       float Nzx = (float) (zx * ct - xx * st);
       float Nzy = (float) (zy * ct - xy * st);
       float Nzz = (float) (zz * ct - xz * st);
       float Nzo = (float) (zo * ct - xo * st);

       xo = Nxo;
       xx = Nxx;
       xy = Nxy;
       xz = Nxz;
       zo = Nzo;
       zx = Nzx;
       zy = Nzy;
       zz = Nzz;
    }
void Matrix3D.yrot ( double  theta) [inline, package]

rotate theta degrees about the y axis

Definition at line 81 of file Matrix3D.java.

                            {
       theta *= (pi / 180);
       double ct = Math.cos(theta);
       double st = Math.sin(theta);

       float Nxx = (float) (xx * ct + zx * st);
       float Nxy = (float) (xy * ct + zy * st);
       float Nxz = (float) (xz * ct + zz * st);
       float Nxo = (float) (xo * ct + zo * st);

       float Nzx = (float) (zx * ct - xx * st);
       float Nzy = (float) (zy * ct - xy * st);
       float Nzz = (float) (zz * ct - xz * st);
       float Nzo = (float) (zo * ct - xo * st);

       xo = Nxo;
       xx = Nxx;
       xy = Nxy;
       xz = Nxz;
       zo = Nzo;
       zx = Nzx;
       zy = Nzy;
       zz = Nzz;
    }

Here is the caller graph for this function:

void Matrix3D.zrot ( double  theta) [inline, package]

rotate theta degrees about the z axis

Definition at line 106 of file Matrix3D.java.

                            {
       theta *= (pi / 180);
       double ct = Math.cos(theta);
       double st = Math.sin(theta);

       float Nyx = (float) (yx * ct + xx * st);
       float Nyy = (float) (yy * ct + xy * st);
       float Nyz = (float) (yz * ct + xz * st);
       float Nyo = (float) (yo * ct + xo * st);

       float Nxx = (float) (xx * ct - yx * st);
       float Nxy = (float) (xy * ct - yy * st);
       float Nxz = (float) (xz * ct - yz * st);
       float Nxo = (float) (xo * ct - yo * st);

       yo = Nyo;
       yx = Nyx;
       yy = Nyy;
       yz = Nyz;
       xo = Nxo;
       xx = Nxx;
       xy = Nxy;
       xz = Nxz;
    }
void Matrix3D.zrot ( double  theta) [inline, package]

rotate theta degrees about the z axis

Definition at line 131 of file Matrix3D.java.

                            {
       theta *= (pi / 180);
       double ct = Math.cos(theta);
       double st = Math.sin(theta);

       float Nyx = (float) (yx * ct + xx * st);
       float Nyy = (float) (yy * ct + xy * st);
       float Nyz = (float) (yz * ct + xz * st);
       float Nyo = (float) (yo * ct + xo * st);

       float Nxx = (float) (xx * ct - yx * st);
       float Nxy = (float) (xy * ct - yy * st);
       float Nxz = (float) (xz * ct - yz * st);
       float Nxo = (float) (xo * ct - yo * st);

       yo = Nyo;
       yx = Nyx;
       yy = Nyy;
       yz = Nyz;
       xo = Nxo;
       xx = Nxx;
       xy = Nxy;
       xz = Nxz;
    }

Member Data Documentation

static final double Matrix3D.pi = 3.14159265 [static, package]

Definition at line 37 of file Matrix3D.java.

float Matrix3D.xo [package]

Definition at line 34 of file Matrix3D.java.

float Matrix3D.xx [package]

Definition at line 34 of file Matrix3D.java.

float Matrix3D.xy [package]

Definition at line 34 of file Matrix3D.java.

float Matrix3D.xz [package]

Definition at line 34 of file Matrix3D.java.

float Matrix3D.yo [package]

Definition at line 35 of file Matrix3D.java.

float Matrix3D.yx [package]

Definition at line 35 of file Matrix3D.java.

float Matrix3D.yy [package]

Definition at line 35 of file Matrix3D.java.

float Matrix3D.yz [package]

Definition at line 35 of file Matrix3D.java.

float Matrix3D.zo [package]

Definition at line 36 of file Matrix3D.java.

float Matrix3D.zx [package]

Definition at line 36 of file Matrix3D.java.

float Matrix3D.zy [package]

Definition at line 36 of file Matrix3D.java.

float Matrix3D.zz [package]

Definition at line 36 of file Matrix3D.java.


The documentation for this class was generated from the following files: