Skip to content
cjcliffe edited this page Oct 15, 2011 · 3 revisions

CubicVR.mat4

The mat4 object provides tools for working with 4x4 Matrices.

Methods:

multiply( m1, m2 )

Multiply one 4x4 Matrix by another.

Parameters:

  • m1 : First Matrix.
  • m2 : Second Matrix.

Returns:

Array of 16 floats representing 4x4 result.

vec4_multiply( v1, m2 )

Transform a 1x4 vector by a 4x4 Matrix.

Parameters:

  • v1 : 1x4 Vector
  • m2 : Second Matrix

Returns:

Transformed 1x4 vector, format: [0.0, 0.0, 0.0, 0.0]

vec3_multiply( v1, m2 )

Transform a 1x3 vector by a 4x4 Matrix.

Parameters:

  • v1 : 1x3 Vector
  • m2 : Second Matrix

Returns:

Transformed 1x3 vector, format: [0.0, 0.0, 0.0]

perspective( fovy, aspect, near, far )

Produce a 4x4 perspective projection matrix.

Parameters:

  • fovy : Field of View in Degrees
  • aspect : Aspect Ratio
  • near : Near Plane
  • far : Far Plane

Returns:

Array of 16 floats representing 4x4 perspective matrix.

lookat( eyeX, eyeY, eyeZ, lookAtX, lookAtY, lookAtZ, upX, upY, upZ )

Emulates gluLookAt() for directly manipulating the camera frustum.

Parameters:

  • eyeX : Eye X coordinate position
  • eyeY : Eye Y coordinate position
  • eyeZ : Eye Z coordinate position
  • lookAtX : Target X coordinate position
  • lookAtY : Target Y coordinate position
  • lookAtZ : Target Z coordinate position
  • upX : Camera up-axis vector, X component
  • upY : Camera up-axis vector, Y component
  • upZ : Camera up-axis vector, Z component

Returns:

Array of 16 floats representing 4x4 "lookAt" transform.

Clone this wiki locally