MaxstARSDK
com.maxst.ar.Matrix Class Reference
Collaboration diagram for com.maxst.ar.Matrix:
Collaboration graph

Static Public Member Functions

static void multiplyMM (float[] output, int outputOffset, float[] lhs, int lhsOffset, float[] rhs, int rhsOffset)
 
static void multiplyMM (float[] output, float[] lhs, float[] rhs)
 
static void multiplyMV (float[] output, int outputOffset, float[] lhs, int lhsOffset, float[] rhs, int rhsOffset)
 
static void multiplyMV (float[] outputV, float[] inputM, float[] inputV)
 
static void multiplyMV3 (float[] outputV, float[] inputM, float[] inputV, float w)
 
static void transposeM (float[] mTrans, int mTransOffset, float[] m, int mOffset)
 
static boolean invertM (float[] mInv, int mInvOffset, float[] m, int mOffset)
 
static void orthoM (float[] m, int mOffset, float left, float right, float bottom, float top, float near, float far)
 
static void frustumM (float[] m, int offset, float left, float right, float bottom, float top, float near, float far)
 
static void perspectiveM (float[] m, int offset, float fovy, float aspect, float zNear, float zFar)
 
static float length (float x, float y, float z)
 
static void setIdentityM (float[] sm, int smOffset)
 
static void scaleM (float[] sm, int smOffset, float[] m, int mOffset, float x, float y, float z)
 
static void scaleM (float[] m, int mOffset, float x, float y, float z)
 
static void translateM (float[] tm, int tmOffset, float[] m, int mOffset, float x, float y, float z)
 
static void translateM (float[] m, int mOffset, float x, float y, float z)
 
static void rotateM (float[] rm, int rmOffset, float[] m, int mOffset, float a, float x, float y, float z)
 
static void rotateM (float[] m, int mOffset, float a, float x, float y, float z)
 
static void setRotateM (float[] rm, int rmOffset, float a, float x, float y, float z)
 
static void setRotateEulerM (float[] rm, int rmOffset, float x, float y, float z)
 
static void setLookAtM (float[] rm, int rmOffset, float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ)
 

Detailed Description

Matrix math utilities. These methods operate on OpenGL ES format matrices and vectors stored in float arrays.

Matrices are 4 x 4 column-vector matrices stored in column-major order:

 m[offset +  0] m[offset +  4] m[offset +  8] m[offset + 12]
 m[offset +  1] m[offset +  5] m[offset +  9] m[offset + 13]
 m[offset +  2] m[offset +  6] m[offset + 10] m[offset + 14]
 m[offset +  3] m[offset +  7] m[offset + 11] m[offset + 15]

Vectors are 4 row x 1 column column-vectors stored in order:

v[offset + 0]
v[offset + 1]
v[offset + 2]
v[offset + 3]

Member Function Documentation

◆ frustumM()

static void com.maxst.ar.Matrix.frustumM ( float[]  m,
int  offset,
float  left,
float  right,
float  bottom,
float  top,
float  near,
float  far 
)
static

Define a projection matrix in terms of six clip planes

Parameters
mthe float array that holds the perspective matrix
offsetthe offset into float array m where the perspective matrix data is written
left
right
bottom
top
near
far

◆ invertM()

static boolean com.maxst.ar.Matrix.invertM ( float[]  mInv,
int  mInvOffset,
float[]  m,
int  mOffset 
)
static

Inverts a 4 x 4 matrix.

Parameters
mInvthe array that holds the output inverted matrix
mInvOffsetan offset into mInv where the inverted matrix is stored.
mthe input array
mOffsetan offset into m where the matrix is stored.
Returns
true if the matrix could be inverted, false if it could not.

◆ length()

static float com.maxst.ar.Matrix.length ( float  x,
float  y,
float  z 
)
static

Computes the length of a vector

Parameters
xx coordinate of a vector
yy coordinate of a vector
zz coordinate of a vector
Returns
the length of a vector
Here is the caller graph for this function:

◆ multiplyMM() [1/2]

static void com.maxst.ar.Matrix.multiplyMM ( float[]  output,
float[]  lhs,
float[]  rhs 
)
static

◆ multiplyMM() [2/2]

static void com.maxst.ar.Matrix.multiplyMM ( float[]  output,
int  outputOffset,
float[]  lhs,
int  lhsOffset,
float[]  rhs,
int  rhsOffset 
)
static

Multiply two 4x4 matrices together and store the result in a third 4x4 matrix. In matrix notation: result = lhs x rhs. Due to the way matrix multiplication works, the result matrix will have the same effect as first multiplying by the rhs matrix, then multiplying by the lhs matrix. This is the opposite of what you might expect.

The same float array may be passed for result, lhs, and/or rhs. However, the result element values are undefined if the result elements overlap either the lhs or rhs elements.

Parameters
resultThe float array that holds the result.
resultOffsetThe offset into the result array where the result is stored.
lhsThe float array that holds the left-hand-side matrix.
lhsOffsetThe offset into the lhs array where the lhs is stored
rhsThe float array that holds the right-hand-side matrix.
rhsOffsetThe offset into the rhs array where the rhs is stored.
Exceptions
IllegalArgumentExceptionif result, lhs, or rhs are null, or if resultOffset + 16 > result.length or lhsOffset + 16 > lhs.length or rhsOffset + 16 > rhs.length. public static void multiplyMM(float[] result, int resultOffset, float[] lhs, int lhsOffset, float[] rhs, int rhsOffset){ android.opengl.Matrix.multiplyMM(result, resultOffset, lhs, lhsOffset, rhs, rhsOffset); }
Here is the caller graph for this function:

◆ multiplyMV() [1/2]

static void com.maxst.ar.Matrix.multiplyMV ( float[]  output,
int  outputOffset,
float[]  lhs,
int  lhsOffset,
float[]  rhs,
int  rhsOffset 
)
static

Multiply a 4 element vector by a 4x4 matrix and store the result in a 4 element column vector. In matrix notation: result = lhs x rhs

The same float array may be passed for resultVec, lhsMat, and/or rhsVec. However, the resultVec element values are undefined if the resultVec elements overlap either the lhsMat or rhsVec elements.

Parameters
resultVecThe float array that holds the result vector.
resultVecOffsetThe offset into the result array where the result vector is stored.
lhsMatThe float array that holds the left-hand-side matrix.
lhsMatOffsetThe offset into the lhs array where the lhs is stored
rhsVecThe float array that holds the right-hand-side vector.
rhsVecOffsetThe offset into the rhs vector where the rhs vector is stored.
Exceptions
IllegalArgumentExceptionif resultVec, lhsMat, or rhsVec are null, or if resultVecOffset + 4 > resultVec.length or lhsMatOffset + 16 > lhsMat.length or rhsVecOffset + 4 > rhsVec.length.

◆ multiplyMV() [2/2]

static void com.maxst.ar.Matrix.multiplyMV ( float[]  outputV,
float[]  inputM,
float[]  inputV 
)
static

◆ multiplyMV3()

static void com.maxst.ar.Matrix.multiplyMV3 ( float[]  outputV,
float[]  inputM,
float[]  inputV,
float  w 
)
static

◆ orthoM()

static void com.maxst.ar.Matrix.orthoM ( float[]  m,
int  mOffset,
float  left,
float  right,
float  bottom,
float  top,
float  near,
float  far 
)
static

Computes an orthographic projection matrix.

Parameters
mreturns the result
mOffset
left
right
bottom
top
near
far

◆ perspectiveM()

static void com.maxst.ar.Matrix.perspectiveM ( float[]  m,
int  offset,
float  fovy,
float  aspect,
float  zNear,
float  zFar 
)
static

Define a projection matrix in terms of a field of view angle, an aspect ratio, and z clip planes

Parameters
mthe float array that holds the perspective matrix
offsetthe offset into float array m where the perspective matrix data is written
fovyfield of view in y direction, in degrees
aspectwidth to height aspect ratio of the viewport
zNear
zFar

◆ rotateM() [1/2]

static void com.maxst.ar.Matrix.rotateM ( float[]  m,
int  mOffset,
float  a,
float  x,
float  y,
float  z 
)
static

Rotates matrix m in place by angle a (in degrees) around the axis (x, y, z)

Parameters
msource matrix
mOffsetindex into m where the matrix starts
aangle to rotate in degrees
xscale factor x
yscale factor y
zscale factor z
Here is the call graph for this function:

◆ rotateM() [2/2]

static void com.maxst.ar.Matrix.rotateM ( float[]  rm,
int  rmOffset,
float[]  m,
int  mOffset,
float  a,
float  x,
float  y,
float  z 
)
static

Rotates matrix m by angle a (in degrees) around the axis (x, y, z)

Parameters
rmreturns the result
rmOffsetindex into rm where the result matrix starts
msource matrix
mOffsetindex into m where the source matrix starts
aangle to rotate in degrees
xscale factor x
yscale factor y
zscale factor z
Here is the call graph for this function:

◆ scaleM() [1/2]

static void com.maxst.ar.Matrix.scaleM ( float[]  m,
int  mOffset,
float  x,
float  y,
float  z 
)
static

Scales matrix m in place by sx, sy, and sz

Parameters
mmatrix to scale
mOffsetindex into m where the matrix starts
xscale factor x
yscale factor y
zscale factor z

◆ scaleM() [2/2]

static void com.maxst.ar.Matrix.scaleM ( float[]  sm,
int  smOffset,
float[]  m,
int  mOffset,
float  x,
float  y,
float  z 
)
static

Scales matrix m by x, y, and z, putting the result in sm

Parameters
smreturns the result
smOffsetindex into sm where the result matrix starts
msource matrix
mOffsetindex into m where the source matrix starts
xscale factor x
yscale factor y
zscale factor z

◆ setIdentityM()

static void com.maxst.ar.Matrix.setIdentityM ( float[]  sm,
int  smOffset 
)
static

Sets matrix m to the identity matrix.

Parameters
smreturns the result
smOffsetindex into sm where the result matrix starts
Here is the caller graph for this function:

◆ setLookAtM()

static void com.maxst.ar.Matrix.setLookAtM ( float[]  rm,
int  rmOffset,
float  eyeX,
float  eyeY,
float  eyeZ,
float  centerX,
float  centerY,
float  centerZ,
float  upX,
float  upY,
float  upZ 
)
static

Define a viewing transformation in terms of an eye point, a center of view, and an up vector.

Parameters
rmreturns the result
rmOffsetindex into rm where the result matrix starts
eyeXeye point X
eyeYeye point Y
eyeZeye point Z
centerXcenter of view X
centerYcenter of view Y
centerZcenter of view Z
upXup vector X
upYup vector Y
upZup vector Z
Here is the call graph for this function:

◆ setRotateEulerM()

static void com.maxst.ar.Matrix.setRotateEulerM ( float[]  rm,
int  rmOffset,
float  x,
float  y,
float  z 
)
static

Converts Euler angles to a rotation matrix

Parameters
rmreturns the result
rmOffsetindex into rm where the result matrix starts
xangle of rotation, in degrees
yangle of rotation, in degrees
zangle of rotation, in degrees

◆ setRotateM()

static void com.maxst.ar.Matrix.setRotateM ( float[]  rm,
int  rmOffset,
float  a,
float  x,
float  y,
float  z 
)
static

Rotates matrix m by angle a (in degrees) around the axis (x, y, z)

Parameters
rmreturns the result
rmOffsetindex into rm where the result matrix starts
aangle to rotate in degrees
xscale factor x
yscale factor y
zscale factor z
Here is the call graph for this function:
Here is the caller graph for this function:

◆ translateM() [1/2]

static void com.maxst.ar.Matrix.translateM ( float[]  m,
int  mOffset,
float  x,
float  y,
float  z 
)
static

Translates matrix m by x, y, and z in place.

Parameters
mmatrix
mOffsetindex into m where the matrix starts
xtranslation factor x
ytranslation factor y
ztranslation factor z

◆ translateM() [2/2]

static void com.maxst.ar.Matrix.translateM ( float[]  tm,
int  tmOffset,
float[]  m,
int  mOffset,
float  x,
float  y,
float  z 
)
static

Translates matrix m by x, y, and z, putting the result in tm

Parameters
tmreturns the result
tmOffsetindex into sm where the result matrix starts
msource matrix
mOffsetindex into m where the source matrix starts
xtranslation factor x
ytranslation factor y
ztranslation factor z
Here is the caller graph for this function:

◆ transposeM()

static void com.maxst.ar.Matrix.transposeM ( float[]  mTrans,
int  mTransOffset,
float[]  m,
int  mOffset 
)
static

Transposes a 4 x 4 matrix.

Parameters
mTransthe array that holds the output inverted matrix
mTransOffsetan offset into mInv where the inverted matrix is stored.
mthe input array
mOffsetan offset into m where the matrix is stored.

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