Drag[en]gine Script Module DragonScript 1.35
Loading...
Searching...
No Matches
Dragengine.Scenery.Matrix4 Class Reference

Immutable 4x4-component row major single precision matrix. More...

Inheritance diagram for Dragengine.Scenery.Matrix4:

Public Member Functions

Management
float getAt (int row, int col)
 Value at row and colon.
float get11 ()
 Value at (1,1).
float get12 ()
 Value at (1,2).
float get13 ()
 Value at (1,3).
float get14 ()
 Value at (1,4).
float get21 ()
 Value at (2,1).
float get22 ()
 Value at (2,2).
float get23 ()
 Value at (2,3).
float get24 ()
 Value at (2,4).
float get31 ()
 Value at (3,1).
float get32 ()
 Value at (3,2).
float get33 ()
 Value at (3,3).
float get34 ()
 Value at (3,4).
float get41 ()
 Value at (4,1).
float get42 ()
 Value at (4,2).
float get43 ()
 Value at (4,3).
float get44 ()
 Value at (4,4).
Vector getViewVector ()
 Vector composed of the third column.
Vector getUpVector ()
 Vector composed of the second column.
Vector getRightVector ()
 Vector composed of the first column.
Vector getPosition ()
 Vector composed of the fourth column.
Vector transformNormal (Vector normal)
 Transform normal by matrix.
Vector getEulerAngles ()
 Euler angles.
Matrix4 getInverse ()
 Inverse.
Matrix4 normalize ()
 Normalize matrix.
Quaternion toQuaternion ()
 Quaternion from upper 3x3 matrix.
DMatrix4 toDMatrix4 ()
 the double precision matrix.
DMatrix toDMatrix ()
 the double precision matrix.
Matrix toMatrix ()
 the single precision matrix.
bool equals (Object other)
 Matrix4 is equal to another object.
int hashCode ()
 Hash code for use as dictionary keys.
String toString ()
 String representation of matrix.
String toString (int precision)
 String representation of matrix with precision.
Operators
Matrix4 operator+ (Matrix4 matrix)
 Sum of matrix with another Matrix4.
Matrix4 operator- (Matrix4 matrix)
 Difference of matrix and another Matrix4.
Matrix4 operator* (float k)
 Matrix4 multiplied by a factor.
Matrix4 operator/ (float k)
 Matrix4 divided by a factor.
Matrix4 operator* (Matrix4 matrix)
 Matrix4 multiplied by another Matrix4.
Vector operator* (Vector vector)
 Vector transformed by matrix.

Constructors

Matrix4 new ()
 Create identity matrix.
Matrix4 new (float a11, float a12, float a13, float a14, float a21, float a22, float a23, float a24, float a31, float a32, float a33, float a34, float a41, float a42, float a43, float a44)
 Create matrix from values.
static Matrix4 newTranslation (Vector translation)
 Create translation matrix.
static Matrix4 newTranslation (float tx, float ty, float tz)
 Create translation matrix.
static Matrix4 newScaling (Vector scaling)
 Create scaling matrix.
static Matrix4 newScaling (float sx, float sy, float sz)
 Create scaling matrix.
static Matrix4 newRotationX (float rotation)
 Create rotation around the x axis matrix.
static Matrix4 newRotationY (float rotation)
 Create rotation around the y axis matrix.
static Matrix4 newRotationZ (float rotation)
 Create rotation around the z axis matrix.
static Matrix4 newRotation (Vector rotation)
 Create rotation matrix.
static Matrix4 newRotation (float rx, float ry, float rz)
 Create rotation matrix.
static Matrix4 newSRT (Vector scaling, Vector rotation, Vector translation)
 Create scaling-rotation-translation matrix composing of a scaling followed by a rotation and a translation.
static Matrix4 newRT (Vector rotation, Vector translation)
 Create rotation-translation matrix composing of a rotation followed by a translation.
static Matrix4 newSVUT (Vector scaling, Vector view, Vector up, Vector translation)
 Create scale-view-up-translation matrix composing of a rotation followed by a world matrix.
static Matrix4 newVU (Vector view, Vector up)
 Create view-up matrix.
static Matrix4 newCamera (Vector position, Vector view, Vector up)
 Create camera matrix.
static Matrix4 newWorld (Vector position, Vector view, Vector up)
 Create world matrix.
static Matrix4 newWorld (Vector position, Quaternion orientation)
 Create world matrix.
static Matrix4 newProjection (int width, int height, float fov, float fovRatio, float znear, float zfar)
 Create projection matrix.
static Matrix4 newOrtho (int left, int right, int top, int bottom, int znear, int zfar)
 Create an orthogonal matrix.
static Matrix4 newFromQuaternion (Quaternion quaternion)
 Create rotation matrix from the given quaternion.

File Handling

void writeToFile (FileWriter writer)
 Write matrix to a file writer.
static Matrix4 readFromFile (FileReader reader)
 Read matrix from a file reader.

Detailed Description

Immutable 4x4-component row major single precision matrix.

This is a native class. It can not be subclassed.

Member Function Documentation

◆ equals()

bool Dragengine.Scenery.Matrix4.equals ( Object other)

Matrix4 is equal to another object.

Implements Object.equals(Object).

Returns
true if other is of type Matrix4 and components are equal.

References get42().

Referenced by operator*().

◆ get11()

float Dragengine.Scenery.Matrix4.get11 ( )

Value at (1,1).

Referenced by get43().

◆ get12()

float Dragengine.Scenery.Matrix4.get12 ( )

Value at (1,2).

References newWorld().

Referenced by get44().

◆ get13()

float Dragengine.Scenery.Matrix4.get13 ( )

Value at (1,3).

References newWorld().

Referenced by getUpVector().

◆ get14()

float Dragengine.Scenery.Matrix4.get14 ( )

Value at (1,4).

Referenced by getPosition().

◆ get21()

float Dragengine.Scenery.Matrix4.get21 ( )

Value at (2,1).

References newProjection().

Referenced by transformNormal().

◆ get22()

float Dragengine.Scenery.Matrix4.get22 ( )

Value at (2,2).

Referenced by getInverse().

◆ get23()

float Dragengine.Scenery.Matrix4.get23 ( )

Value at (2,3).

References newOrtho().

Referenced by getInverse().

◆ get24()

float Dragengine.Scenery.Matrix4.get24 ( )

Value at (2,4).

References newFromQuaternion().

Referenced by getInverse().

◆ get31()

float Dragengine.Scenery.Matrix4.get31 ( )

Value at (3,1).

Referenced by normalize().

◆ get32()

float Dragengine.Scenery.Matrix4.get32 ( )

Value at (3,2).

Referenced by toQuaternion().

◆ get33()

float Dragengine.Scenery.Matrix4.get33 ( )

Value at (3,3).

Referenced by toDMatrix().

◆ get34()

float Dragengine.Scenery.Matrix4.get34 ( )

Value at (3,4).

Referenced by toMatrix().

◆ get41()

float Dragengine.Scenery.Matrix4.get41 ( )

Value at (4,1).

References getAt().

Referenced by toMatrix().

◆ get42()

float Dragengine.Scenery.Matrix4.get42 ( )

Value at (4,2).

Referenced by equals().

◆ get43()

float Dragengine.Scenery.Matrix4.get43 ( )

Value at (4,3).

References get11().

Referenced by hashCode().

◆ get44()

float Dragengine.Scenery.Matrix4.get44 ( )

Value at (4,4).

References get12().

Referenced by toString().

◆ getAt()

float Dragengine.Scenery.Matrix4.getAt ( int row,
int col )

Value at row and colon.

Exceptions
EInvalidParamrow is less than 0 or larger than 3.
EInvalidParamcol is less than 0 or larger than 3.

References newCamera().

Referenced by get41().

◆ getEulerAngles()

Vector Dragengine.Scenery.Matrix4.getEulerAngles ( )

Euler angles.

Referenced by operator-().

◆ getInverse()

Matrix4 Dragengine.Scenery.Matrix4.getInverse ( )

Inverse.

References get22(), get23(), and get24().

Referenced by operator*().

◆ getPosition()

Vector Dragengine.Scenery.Matrix4.getPosition ( )

Vector composed of the fourth column.

References get14().

Referenced by writeToFile().

◆ getRightVector()

Vector Dragengine.Scenery.Matrix4.getRightVector ( )

Vector composed of the first column.

Referenced by toString().

◆ getUpVector()

Vector Dragengine.Scenery.Matrix4.getUpVector ( )

Vector composed of the second column.

References get13().

Referenced by toString().

◆ getViewVector()

Vector Dragengine.Scenery.Matrix4.getViewVector ( )

Vector composed of the third column.

Referenced by toString().

◆ hashCode()

int Dragengine.Scenery.Matrix4.hashCode ( )

Hash code for use as dictionary keys.

Implements Object.hashCode().

References get43().

Referenced by operator*().

◆ new() [1/2]

Matrix4 Dragengine.Scenery.Matrix4.new ( )

Create identity matrix.

References new().

Referenced by new(), and new().

◆ new() [2/2]

Matrix4 Dragengine.Scenery.Matrix4.new ( float a11,
float a12,
float a13,
float a14,
float a21,
float a22,
float a23,
float a24,
float a31,
float a32,
float a33,
float a34,
float a41,
float a42,
float a43,
float a44 )

Create matrix from values.

References new().

◆ newCamera()

Matrix4 Dragengine.Scenery.Matrix4.newCamera ( Vector position,
Vector view,
Vector up )
static

Create camera matrix.

Referenced by getAt().

◆ newFromQuaternion()

Matrix4 Dragengine.Scenery.Matrix4.newFromQuaternion ( Quaternion quaternion)
static

Create rotation matrix from the given quaternion.

References newSVUT(), and newVU().

Referenced by get24().

◆ newOrtho()

Matrix4 Dragengine.Scenery.Matrix4.newOrtho ( int left,
int right,
int top,
int bottom,
int znear,
int zfar )
static

Create an orthogonal matrix.

References newRT().

Referenced by get23().

◆ newProjection()

Matrix4 Dragengine.Scenery.Matrix4.newProjection ( int width,
int height,
float fov,
float fovRatio,
float znear,
float zfar )
static

Create projection matrix.

Referenced by get21().

◆ newRotation() [1/2]

Matrix4 Dragengine.Scenery.Matrix4.newRotation ( float rx,
float ry,
float rz )
static

Create rotation matrix.

◆ newRotation() [2/2]

Matrix4 Dragengine.Scenery.Matrix4.newRotation ( Vector rotation)
static

Create rotation matrix.

References newRotationX().

Referenced by newVU(), and newWorld().

◆ newRotationX()

Matrix4 Dragengine.Scenery.Matrix4.newRotationX ( float rotation)
static

Create rotation around the x axis matrix.

References newScaling().

Referenced by newRotation().

◆ newRotationY()

Matrix4 Dragengine.Scenery.Matrix4.newRotationY ( float rotation)
static

Create rotation around the y axis matrix.

References newScaling().

Referenced by newSRT().

◆ newRotationZ()

Matrix4 Dragengine.Scenery.Matrix4.newRotationZ ( float rotation)
static

Create rotation around the z axis matrix.

Referenced by newRT().

◆ newRT()

Matrix4 Dragengine.Scenery.Matrix4.newRT ( Vector rotation,
Vector translation )
static

Create rotation-translation matrix composing of a rotation followed by a translation.

References newRotationZ().

Referenced by newOrtho().

◆ newScaling() [1/2]

Matrix4 Dragengine.Scenery.Matrix4.newScaling ( float sx,
float sy,
float sz )
static

Create scaling matrix.

◆ newScaling() [2/2]

Matrix4 Dragengine.Scenery.Matrix4.newScaling ( Vector scaling)
static

Create scaling matrix.

References newTranslation().

Referenced by newRotationX(), and newRotationY().

◆ newSRT()

Matrix4 Dragengine.Scenery.Matrix4.newSRT ( Vector scaling,
Vector rotation,
Vector translation )
static

Create scaling-rotation-translation matrix composing of a scaling followed by a rotation and a translation.

References newRotationY().

Referenced by newWorld().

◆ newSVUT()

Matrix4 Dragengine.Scenery.Matrix4.newSVUT ( Vector scaling,
Vector view,
Vector up,
Vector translation )
static

Create scale-view-up-translation matrix composing of a rotation followed by a world matrix.

Referenced by newFromQuaternion().

◆ newTranslation() [1/2]

Matrix4 Dragengine.Scenery.Matrix4.newTranslation ( float tx,
float ty,
float tz )
static

Create translation matrix.

◆ newTranslation() [2/2]

Matrix4 Dragengine.Scenery.Matrix4.newTranslation ( Vector translation)
static

Create translation matrix.

References newTranslation().

Referenced by newScaling(), and newTranslation().

◆ newVU()

Matrix4 Dragengine.Scenery.Matrix4.newVU ( Vector view,
Vector up )
static

Create view-up matrix.

References newRotation().

Referenced by newFromQuaternion().

◆ newWorld() [1/2]

Matrix4 Dragengine.Scenery.Matrix4.newWorld ( Vector position,
Quaternion orientation )
static

Create world matrix.

References newSRT().

◆ newWorld() [2/2]

Matrix4 Dragengine.Scenery.Matrix4.newWorld ( Vector position,
Vector view,
Vector up )
static

Create world matrix.

References newRotation().

Referenced by get12(), and get13().

◆ normalize()

Matrix4 Dragengine.Scenery.Matrix4.normalize ( )

Normalize matrix.

Returns matrix with scaling removed. Only normalized matrices are safe to be used with the getEulerAngles() and toQuaternion() calls since scaling interferes with the calculation.

This calls the same as this code

DMatrix.newWorld(m.getPosition(), getViewVector(), m.getUpVector())
Immutable 4x3-component row major double precision matrix.
Definition DMatrix.ds:17
static DMatrix newWorld(DVector position, DVector view, DVector up)
Create world matrix.
Vector getViewVector()
Vector composed of the third column.

but is safe against 0-scaling. In such a case a 0-rotation matrix is created.

References get31().

Referenced by operator*().

◆ operator*() [1/3]

Matrix4 Dragengine.Scenery.Matrix4.operator* ( float k)

Matrix4 multiplied by a factor.

References getInverse().

◆ operator*() [2/3]

Matrix4 Dragengine.Scenery.Matrix4.operator* ( Matrix4 matrix)

Matrix4 multiplied by another Matrix4.

◆ operator*() [3/3]

Vector Dragengine.Scenery.Matrix4.operator* ( Vector vector)

◆ operator+()

Matrix4 Dragengine.Scenery.Matrix4.operator+ ( Matrix4 matrix)

Sum of matrix with another Matrix4.

◆ operator-()

Matrix4 Dragengine.Scenery.Matrix4.operator- ( Matrix4 matrix)

Difference of matrix and another Matrix4.

References getEulerAngles().

◆ operator/()

Matrix4 Dragengine.Scenery.Matrix4.operator/ ( float k)

Matrix4 divided by a factor.

Exceptions
EDivisionByZeroscalar is 0.

◆ readFromFile()

Matrix4 Dragengine.Scenery.Matrix4.readFromFile ( FileReader reader)
static

Read matrix from a file reader.

Referenced by operator*().

◆ toDMatrix()

DMatrix Dragengine.Scenery.Matrix4.toDMatrix ( )

the double precision matrix.

References get33().

Referenced by operator*().

◆ toDMatrix4()

DMatrix4 Dragengine.Scenery.Matrix4.toDMatrix4 ( )

the double precision matrix.

Referenced by operator*().

◆ toMatrix()

Matrix Dragengine.Scenery.Matrix4.toMatrix ( )

the single precision matrix.

References get34(), and get41().

Referenced by operator*().

◆ toQuaternion()

Quaternion Dragengine.Scenery.Matrix4.toQuaternion ( )

Quaternion from upper 3x3 matrix.

References get32().

Referenced by operator*().

◆ toString() [1/2]

String Dragengine.Scenery.Matrix4.toString ( )

String representation of matrix.

Implements Object.toString()

References get44(), and getViewVector().

Referenced by operator*().

◆ toString() [2/2]

String Dragengine.Scenery.Matrix4.toString ( int precision)

String representation of matrix with precision.

Same as toString() except the count of digits of each component is precision.

Parameters
precisionPrecision in digits in the range from 0 to 9 inclusive.
Exceptions
EInvalidParamprecision is less than 0 or larger than 9.

References getRightVector(), and getUpVector().

◆ transformNormal()

Vector Dragengine.Scenery.Matrix4.transformNormal ( Vector normal)

Transform normal by matrix.

References get21().

Referenced by writeToFile().

◆ writeToFile()

void Dragengine.Scenery.Matrix4.writeToFile ( FileWriter writer)

Write matrix to a file writer.

References getPosition(), and transformNormal().

Referenced by operator*().


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