Class Matrix

java.lang.Object
javaforce.gl.Matrix
All Implemented Interfaces:
Cloneable

public class Matrix extends Object implements Cloneable
4x4 matrix
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    float[]
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addRotate(float angle, float ax, float ay, float az)
    Adds rotation assuming there is currently no translation.
    void
    addRotate2(float angle, float ax, float ay, float az)
    Adds rotation with current translation.
    void
    addRotate3(float angle, float ax, float ay, float az)
    Adds rotation adjusted to current rotation but assuming there is currently no translation.
    void
    addRotate4(float angle, float ax, float ay, float az)
    Adds rotation adjusted to current rotation with current translation.
    void
    addScale(float sx, float sy, float sz)
    Adds scale using full matrix multiple.
    void
    addTranslate(float tx, float ty, float tz)
    Adds translation assuming there is currently no rotation.
    void
    Adds translation assuming there is currently no rotation.
    void
    addTranslate2(float tx, float ty, float tz)
    Adds translation with current rotation.
    void
    addTranslate3(float tx, float ty, float tz)
    Adds translation adjusted for scaling assuming there is currently no rotation.
    void
    addTranslate4(float tx, float ty, float tz)
    Adds translation adjusted for scaling with current rotation.
     
    float
    Return the determinant.
    void
    frustum(float left, float right, float bottom, float top, float znear, float zfar)
     
    float
    get(int i, int j)
     
    boolean
    Full matrix inversion in place.
    void
    lookAt(Vector3 eye, Vector3 at, Vector3 up)
    Sets the matrix to look at a point from a specified point.
    void
    mult(Matrix src)
    3x3 matrix multiple (rotation only)
    void
    mult(Vector3 dest)
    Multiply another 3x1 matrix with this one (3x3 part only) Effectively rotates the Vector3 by the rotation of this matrix
    void
    mult(Vector4 dest)
    Multiply another 4x1 matrix with this one (full matrix)
    void
    Multiply this matrix with another (rotation/scale only)
    void
    Multiply this matrix with another
    void
    ortho(float left, float right, float bottom, float top, float near, float far)
     
    void
    perspective(float fovyInDegrees, float aspectRatio, float znear, float zfar)
     
    void
     
    void
    set(int i, int j, float v)
     
    void
    set(Matrix src)
     
    void
    Set rotation from Quaternion.
    void
    setAA(float angle, float x, float y, float z)
     
    void
    setAATranslate(float angle, float x, float y, float z, float tx, float ty, float tz)
     
    void
     
    void
     
    void
    setScale(float x, float y, float z)
     
    void
    setTranslate(float x, float y, float z)
     
     
    void
    Transpose this matrix in place.

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • Matrix

      public Matrix()
  • Method Details

    • clone

      public Object clone()
      Overrides:
      clone in class Object
    • setIdentity

      public void setIdentity()
    • setIdentity3x3

      public void setIdentity3x3()
    • set

      public void set(Matrix src)
    • setAA

      public void setAA(float angle, float x, float y, float z)
    • set

      public void set(Quaternion q)
      Set rotation from Quaternion.
    • setAATranslate

      public void setAATranslate(float angle, float x, float y, float z, float tx, float ty, float tz)
    • setTranslate

      public void setTranslate(float x, float y, float z)
    • setScale

      public void setScale(float x, float y, float z)
    • addRotate

      public void addRotate(float angle, float ax, float ay, float az)
      Adds rotation assuming there is currently no translation.
    • addRotate2

      public void addRotate2(float angle, float ax, float ay, float az)
      Adds rotation with current translation.
    • addRotate3

      public void addRotate3(float angle, float ax, float ay, float az)
      Adds rotation adjusted to current rotation but assuming there is currently no translation.
    • addRotate4

      public void addRotate4(float angle, float ax, float ay, float az)
      Adds rotation adjusted to current rotation with current translation.
    • addTranslate

      public void addTranslate(float tx, float ty, float tz)
      Adds translation assuming there is currently no rotation.
    • addTranslate

      public void addTranslate(Matrix src)
      Adds translation assuming there is currently no rotation.
    • addTranslate2

      public void addTranslate2(float tx, float ty, float tz)
      Adds translation with current rotation.
    • addTranslate3

      public void addTranslate3(float tx, float ty, float tz)
      Adds translation adjusted for scaling assuming there is currently no rotation. Warning : Any zero scaling will result in divide by zero.
    • addTranslate4

      public void addTranslate4(float tx, float ty, float tz)
      Adds translation adjusted for scaling with current rotation. Warning : Any zero scaling will result in divide by zero.
    • addScale

      public void addScale(float sx, float sy, float sz)
      Adds scale using full matrix multiple.
    • mult4x4

      public void mult4x4(Matrix src)
      Multiply this matrix with another
    • mult3x3

      public void mult3x3(Matrix src)
      Multiply this matrix with another (rotation/scale only)
    • mult

      public void mult(Matrix src)
      3x3 matrix multiple (rotation only)
    • mult

      public void mult(Vector3 dest)
      Multiply another 3x1 matrix with this one (3x3 part only) Effectively rotates the Vector3 by the rotation of this matrix
    • mult

      public void mult(Vector4 dest)
      Multiply another 4x1 matrix with this one (full matrix)
    • get

      public float get(int i, int j)
    • set

      public void set(int i, int j, float v)
    • transpose

      public void transpose()
      Transpose this matrix in place.
    • determinant

      public float determinant()
      Return the determinant. Computed across the zeroth row.
    • invert

      public boolean invert()
      Full matrix inversion in place. If matrix is singular, returns false and matrix contents are untouched. If you know the matrix is orthonormal, you can call transpose() instead.
    • reverseTranslate

      public void reverseTranslate()
    • frustum

      public void frustum(float left, float right, float bottom, float top, float znear, float zfar)
    • perspective

      public void perspective(float fovyInDegrees, float aspectRatio, float znear, float zfar)
    • ortho

      public void ortho(float left, float right, float bottom, float top, float near, float far)
    • lookAt

      public void lookAt(Vector3 eye, Vector3 at, Vector3 up)
      Sets the matrix to look at a point from a specified point. Note:input vectors are clobbered.
      Parameters:
      eye - = camera position
      at - = point to look at
      up - = camera up vector (usually 0,1,0)
    • toString

      public String toString()
      Overrides:
      toString in class Object