GLKMatrix3 Reference
| Framework | GLKit/GLKMath.h |
| Declared in | GLKMathTypes.h GLKMatrix3.h |
Overview
The GKLMatrix3 type defines a 3x3 floating-point matrix as well as many mathematical operations commonly used to manipulate matrices. A 3x3 matrix is commonly used in graphics programming to represent scaling or rotation transformations to convert from one coordinate system to another.
The functions that manipulate GKLMatrix3 structures treat the inputs as immutable, instead returning a new matrix that represent the results of the operation.
Functions by Task
Creating Matrices
-
GLKMatrix3Make -
GLKMatrix3MakeAndTranspose -
GLKMatrix3MakeWithArray -
GLKMatrix3MakeWithArrayAndTranspose -
GLKMatrix3MakeWithColumns -
GLKMatrix3MakeWithRows -
GLKMatrix3MakeRotation -
GLKMatrix3MakeXRotation -
GLKMatrix3MakeYRotation -
GLKMatrix3MakeZRotation -
GLKMatrix3MakeWithQuaternion -
GLKMatrix3MakeScale
Working With Parts of a Matrix
Performing Mathematical Operations on Matrices
-
GLKMatrix3Invert -
GLKMatrix3Transpose -
GLKMatrix3InvertAndTranspose -
GLKMatrix3Multiply -
GLKMatrix3Rotate -
GLKMatrix3RotateWithVector3 -
GLKMatrix3RotateWithVector4 -
GLKMatrix3RotateX -
GLKMatrix3RotateY -
GLKMatrix3RotateZ -
GLKMatrix3Scale -
GLKMatrix3ScaleWithVector3 -
GLKMatrix3ScaleWithVector4 -
GLKMatrix3Add -
GLKMatrix3Subtract
Performing Mathematical Operations on Vectors
Functions
GLKMatrix3Add
Returns a new 3x3 matrix created by performing a component-wise addition of two matrices.
GLKMatrix3 GLKMatrix3Add ( GLKMatrix3 matrixLeft, GLKMatrix3 matrixRight );
Parameters
- matrixLeft
The first matrix.
- matrixRight
The second matrix.
Return Value
A new matrix whose components each represent the sum of the components found in the same positions of the two source matrices.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3GetColumn
Retrieves a column from a 3x3 matrix.
GLKVector3 GLKMatrix3GetColumn ( GLKMatrix3 matrix, int column );
Parameters
- matrix
A
3x3matrix.- column
The column index, which must be a number between
0and2, inclusive.
Return Value
A vector representing the column retrieved from the matrix.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3GetMatrix2
Returns the upper-left 2x2 section of a 3x3 matrix.
GLKMatrix2 GLKMatrix3GetMatrix2 ( GLKMatrix3 matrix );
Parameters
- matrix
A matrix.
Return Value
A new 2x2 matrix.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3GetRow
Retrieves a row from a 3x3 matrix.
GLKVector3 GLKMatrix3GetRow ( GLKMatrix3 matrix, int row );
Parameters
- matrix
A
3x3matrix.- row
The row index, which must be a number between
0and2, inclusive.
Return Value
A vector representing the row retrieved from the matrix.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3Invert
Returns the inverse of a matrix.
GLKMatrix3 GLKMatrix3Invert ( GLKMatrix3 matrix, bool *isInvertible );
Parameters
- matrix
A matrix.
- isInvertible
On return, this holds
YESif the matrix was inverted orNOif the matrix is not invertible.
Return Value
If isInvertible was set to YES, this holds an inverted matrix. Otherwise, the contents are invalid.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3InvertAndTranspose
Returns the inverse transpose of a matrix.
GLKMatrix3 GLKMatrix3InvertAndTranspose ( GLKMatrix3 matrix, bool *isInvertible );
Parameters
- matrix
A matrix.
- isInvertible
On return, this holds
YESif the matrix was inverted orNOif the matrix is not invertible.
Return Value
If isInvertible was set to YES, this holds an inverted and transposed matrix. Otherwise, the contents are invalid.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3Make
Returns a 3x3 matrix created from individual component values.
GLKMatrix3 GLKMatrix3Make ( float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22 );
Parameters
- m00
The value for position [0,0] in the returned matrix.
- m01
The value for position [0,1] in the returned matrix.
- m02
The value for position [0,2] in the returned matrix.
- m10
The value for position [1,0] in the returned matrix.
- m11
The value for position [1,1] in the returned matrix.
- m12
The value for position [1,2] in the returned matrix.
- m20
The value for position [2,0] in the returned matrix.
- m21
The value for position [2,1] in the returned matrix.
- m22
The value for position [2,2] in the returned matrix.
Return Value
A new matrix.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3MakeAndTranspose
Returns a 3x3 transposed matrix created from individual component values.
GLKMatrix3 GLKMatrix3MakeAndTranspose ( float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22 );
Parameters
- m00
The value for position [0,0] in the returned matrix.
- m01
The value for position [1,0] in the returned matrix.
- m02
The value for position [2,0] in the returned matrix.
- m10
The value for position [0,1] in the returned matrix.
- m11
The value for position [1,1] in the returned matrix.
- m12
The value for position [2,1] in the returned matrix.
- m20
The value for position [0,2] in the returned matrix.
- m21
The value for position [1,2] in the returned matrix.
- m22
The value for position [2,2] in the returned matrix.
Return Value
A new matrix.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3MakeRotation
Returns a 3x3 matrix that performs a rotation around an arbitrary vector.
GLKMatrix3 GLKMatrix3MakeRotation ( float radians, float x, float y, float z );
Parameters
- radians
The angle of the rotation (a positive angle is counterclockwise).
- x
The
xcomponent of the rotation vector.- y
The
ycomponent of the rotation vector.- z
The
zcomponent of the rotation vector.
Return Value
A new rotation matrix.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3MakeScale
Returns a 3x3 matrix that performs a scaling transformation.
GLKMatrix3 GLKMatrix3MakeScale ( float sx, float sy, float sz );
Parameters
- sx
The amount to scale the
xcomponent.- sy
The amount to scale the
ycomponent.- sz
The amount to scale the
zcomponent.
Return Value
A new scaling matrix.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3MakeWithArray
Returns a 3x3 matrix created from an array of component values.
GLKMatrix3 GLKMatrix3MakeWithArray ( float values[9] );
Parameters
- float values[9]
The set of component values, in column-major order.
Return Value
A new matrix.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3MakeWithArrayAndTranspose
Returns a 3x3 transposed matrix created from an array of component values.
GLKMatrix3 GLKMatrix3MakeWithArrayAndTranspose ( float values[9] );
Parameters
- float values[9]
The set of component values, in column-major order.
Return Value
A new matrix.
Discussion
The matrix is created and then transposed, before being returned to your application.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3MakeWithColumns
Returns a 3x3 matrix created from three column vectors.
GLKMatrix3 GLKMatrix3MakeWithColumns ( GLKVector3 column0, GLKVector3 column1, GLKVector3 column2 );
Parameters
- column0
The first column.
- column1
The second column.
- column2
The third column.
Return Value
A new matrix.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3MakeWithQuaternion
Returns a 3x3 matrix that performs a rotation based on a quaternion.
GLKMatrix3 GLKMatrix3MakeWithQuaternion ( GLKQuaternion quaternion );
Parameters
- quaternion
The quaternion.
Return Value
A new matrix that provides an equivalent rotation to that stored in the quaternion.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3MakeWithRows
Returns a 3x3 matrix created from three row vectors.
GLKMatrix3 GLKMatrix3MakeWithRows ( GLKVector3 row0, GLKVector3 row1, GLKVector3 row2 );
Parameters
- row0
The first row.
- row1
The second row.
- row2
The third row.
Return Value
A new matrix.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3MakeXRotation
Returns a 3x3 matrix that performs a rotation around the positive x-axis.
GLKMatrix3 GLKMatrix3MakeXRotation ( float radians );
Parameters
- radians
The angle of the rotation (a positive angle is counterclockwise).
Return Value
A new rotation matrix.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3MakeYRotation
Returns a 3x3 matrix that performs a rotation around the positive y-axis.
GLKMatrix3 GLKMatrix3MakeYRotation ( float radians );
Parameters
- radians
The angle of the rotation (a positive angle is counterclockwise).
Return Value
A new rotation matrix.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3MakeZRotation
Returns a 3x3 matrix that performs a rotation around the positive z-axis.
GLKMatrix3 GLKMatrix3MakeZRotation ( float radians );
Parameters
- radians
The angle of the rotation (a positive angle is counterclockwise).
Return Value
A new rotation matrix.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3Multiply
Returns the product of two matrices.
GLKMatrix3 GLKMatrix3Multiply ( GLKMatrix3 matrixLeft, GLKMatrix3 matrixRight );
Parameters
- matrixLeft
The multiplicand.
- matrixRight
The multiplier.
Return Value
A new matrix.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3MultiplyVector3
Multiplies a 3x3 matrix by a vector.
GLKVector3 GLKMatrix3MultiplyVector3 ( GLKMatrix3 matrixLeft, GLKVector3 vectorRight );
Parameters
- matrixLeft
The matrix multiplicand.
- vectorRight
The vector multiplier.
Return Value
A new vector created by multiplying the matrix by the vector.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3MultiplyVector3Array
Multiplies a 3x3 matrix by an array of vectors.
void GLKMatrix3MultiplyVector3Array ( GLKMatrix3 matrix, GLKVector3 *vectors, size_t vectorCount );
Parameters
- matrix
The matrix multiplicand.
- vectors
On entry, an array of input vectors. On return, an array of output vectors.
- vectorCount
The number of vectors in the array.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3Rotate
Returns a new 3x3 matrix created by concatenating a matrix with a rotation around a vector.
GLKMatrix3 GLKMatrix3Rotate ( GLKMatrix3 matrix, float radians, float x, float y, float z );
Parameters
- matrix
The source matrix.
- radians
The angle of the rotation (a positive angle is counterclockwise).
- x
The
xcomponent of the rotation vector.- y
The
ycomponent of the rotation vector.- z
The
zcomponent of the rotation vector.
Return Value
A new matrix.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3RotateWithVector3
Returns a new 3x3 matrix created by concatenating a matrix with a rotation around a vector.
GLKMatrix3 GLKMatrix3RotateWithVector3 ( GLKMatrix3 matrix, float radians, GLKVector3 axisVector );
Parameters
- matrix
The source matrix.
- radians
The angle of the rotation (a positive angle is counterclockwise).
- axisVector
The axis to perform the rotation around.
Return Value
A new matrix.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3RotateWithVector4
Returns a new 3x3 matrix created by concatenating a matrix with a rotation around a vector.
GLKMatrix3 GLKMatrix3RotateWithVector4 ( GLKMatrix3 matrix, float radians, GLKVector4 axisVector );
Parameters
- matrix
The source matrix.
- radians
The angle of the rotation (a positive angle is counterclockwise).
- axisVector
The axis to perform the rotation around.
Return Value
A new matrix.
Discussion
The w-component of the axisVector parameter is ignored.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3RotateX
Returns a new 3x3 matrix created by concatenating a matrix with a rotation around the x-axis.
GLKMatrix3 GLKMatrix3RotateX ( GLKMatrix3 matrix, float radians );
Parameters
- matrix
The source matrix.
- radians
The angle of the rotation (a positive angle is counterclockwise).
Return Value
A new matrix.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3RotateY
Returns a new 3x3 matrix created by concatenating a matrix with a rotation around the y-axis.
GLKMatrix3 GLKMatrix3RotateY ( GLKMatrix3 matrix, float radians );
Parameters
- matrix
The source matrix.
- radians
The angle of the rotation.
Return Value
A new matrix.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3RotateZ
Returns a new 3x3 matrix created by concatenating a matrix with a rotation around the z-axis.
GLKMatrix3 GLKMatrix3RotateZ ( GLKMatrix3 matrix, float radians );
Parameters
- matrix
The source matrix.
- radians
The angle of the rotation (a positive angle is counterclockwise).
Return Value
A new matrix.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3Scale
Returns a new 3x3 matrix created by concatenating a matrix with a scaling transform.
GLKMatrix3 GLKMatrix3Scale ( GLKMatrix3 matrix, float sx, float sy, float sz );
Parameters
- matrix
The source matrix.
- sx
The amount to scale the
xcomponent.- sy
The amount to scale the
ycomponent.- sz
The amount to scale the
zcomponent.
Return Value
A new matrix.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3ScaleWithVector3
Returns a new 3x3 matrix created by concatenating a matrix with a scaling transform defined by a vector.
GLKMatrix3 GLKMatrix3ScaleWithVector3 ( GLKMatrix3 matrix, GLKVector3 scaleVector );
Parameters
- matrix
The source matrix.
- scaleVector
A vector whose
x,yandzcomponents are used to scale the matrix.
Return Value
A new matrix.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3ScaleWithVector4
Returns a new 3x3 matrix created by concatenating a matrix with a scaling transform defined by a vector.
GLKMatrix3 GLKMatrix3ScaleWithVector4 ( GLKMatrix3 matrix, GLKVector4 scaleVector );
Parameters
- matrix
The source matrix.
- scaleVector
A vector whose
x,yandzcomponents are used to scale the matrix.
Return Value
A new matrix.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3SetColumn
Returns a new 3x3 matrix with one column replaced by a new vector.
GLKMatrix3 GLKMatrix3SetColumn ( GLKMatrix3 matrix, int column, GLKVector3 vector );
Parameters
- matrix
The source matrix.
- column
The index of the column to replace, which must be a number between
0and2, inclusive.- vector
A vector holding the replacement component values.
Return Value
A new matrix.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3SetRow
Returns a new 3x3 matrix with one row replaced by a new vector.
GLKMatrix3 GLKMatrix3SetRow ( GLKMatrix3 matrix, int row, GLKVector3 vector );
Parameters
- matrix
The source matrix.
- row
The index of the row to replace, which must be a number between
0and2, inclusive.- vector
A vector holding the replacement component values.
Return Value
A new matrix.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3Subtract
Returns a new 3x3 matrix created by performing a component-wise subtraction of two matrices.
GLKMatrix3 GLKMatrix3Subtract ( GLKMatrix3 matrixLeft, GLKMatrix3 matrixRight );
Parameters
- matrixLeft
The starting matrix.
- matrixRight
The matrix to subtract.
Return Value
A new matrix whose components each represent the difference between the components found in the same positions of the two source matrices.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hGLKMatrix3Transpose
Returns the transpose of a matrix.
GLKMatrix3 GLKMatrix3Transpose ( GLKMatrix3 matrix );
Parameters
- matrix
A matrix.
Return Value
The transpose of the matrix.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMatrix3.hData Types
GLKMatrix2
A 2x2 matrix.
union _GLKMatrix2
{
struct
{
float m00, m01;
float m10, m11;
};
float m2[2][2];
float m[4];
};
typedef union _GLKMatrix2 GLKMatrix2;
Fields
m00The
[0,0]element of the matrix.m01The
[0,1]element of the matrix.m10The
[1,0]element of the matrix.m11The
[1,1]element of the matrix.m2A two-dimensional array of the matrix's elements in column-major order.
mA one-dimensional array of the matrix’s elements in column-major order.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMathTypes.hGLKMatrix3
A 3x3 matrix stored in column-major order.
union _GLKMatrix3
{
struct
{
float m00, m01, m02;
float m10, m11, m12;
float m20, m21, m22;
};
float m[9];
};
typedef union _GLKMatrix3 GLKMatrix3;
Fields
m00The
[0,0]element of the matrix.m01The
[0,1]element of the matrix.m02The
[0,2]element of the matrix.m10The
[1,0]element of the matrix.m11The
[1,1]element of the matrix.m12The
[1,2]element of the matrix.m20The
[2,0]element of the matrix.m21The
[2,1]element of the matrix.m22The
[2,2]element of the matrix.mA one-dimensional array of the matrix’s elements in column-major order.
Availability
- Available in iOS 5.0 and later.
Declared In
GLKMathTypes.hConstants
GLKMatrix3Identity
A 3x3 identity matrix.
extern const GLKMatrix3 GLKMatrix3Identity;
Constants
GLKMatrix3IdentityA
3x3identity matrix.Available in iOS 5.0 and later.
Declared in
GLKMatrix3.h.
© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-07-17)