CC3LinearMatrix Class Reference
Inherits from | CC3Matrix : NSObject |
Declared in | CC3LinearMatrix.h |
Overview
CC3LinearMatrix is a 3x3 matrix that can represent 3D linear transforms such as rotation, scaling, reflection and shearing. Matrices of this class cannot represent 3D translation.
Internally, the dimensions of this matrix are three columns by three rows. Data is held in a CC3Matrix3x3 structure of 9 GLfloat elements in column-major order. For situations requiring only 3D linear transformations, this offers a storage savings over using a full 4x4 matrix.
Tasks
-
– populateFromTranslation:
-
– populateToLookAt:withEyeAt:withUp:
-
– populateFromFrustumLeft:andRight:andTop:andBottom:andNear:andFar:
-
– populateFromFrustumLeft:andRight:andTop:andBottom:andNear:
-
– populateOrthoFromFrustumLeft:andRight:andTop:andBottom:andNear:andFar:
-
– populateOrthoFromFrustumLeft:andRight:andTop:andBottom:andNear:
-
– transformLocation:
-
– transformHomogeneousVector:
Instance Methods
populateFromFrustumLeft:andRight:andTop:andBottom:andNear:
Populates this matrix as an infinite-depth perspective projection matrix with the specified frustum dimensions, where the far clipping plane is set at an infinite distance.
- (void)populateFromFrustumLeft:(GLfloat)left andRight:(GLfloat)right andTop:(GLfloat)top andBottom:(GLfloat)bottom andNear:(GLfloat)near
Discussion
Linear matrices cannot support perspective projection. This method throws an assertion exception.
Declared In
CC3LinearMatrix.h
populateFromFrustumLeft:andRight:andTop:andBottom:andNear:andFar:
Populates this matrix as a perspective projection matrix with the specified frustum dimensions.
- (void)populateFromFrustumLeft:(GLfloat)left andRight:(GLfloat)right andTop:(GLfloat)top andBottom:(GLfloat)bottom andNear:(GLfloat)near andFar:(GLfloat)far
Discussion
Linear matrices cannot support perspective projection. This method throws an assertion exception.
Declared In
CC3LinearMatrix.h
populateFromTranslation:
Populates this instance from the specified translation vector.
- (void)populateFromTranslation:(CC3Vector)aTranslation
Discussion
Since linear matrices are unaffected by translation, the effect of this method is to populate this matrix as a identity matrix.
Declared In
CC3LinearMatrix.h
populateOrthoFromFrustumLeft:andRight:andTop:andBottom:andNear:
Populates this matrix as an infinite-depth orthographic projection matrix with the specified frustum dimensions, where the far clipping plane is set at an infinite distance.
- (void)populateOrthoFromFrustumLeft:(GLfloat)left andRight:(GLfloat)right andTop:(GLfloat)top andBottom:(GLfloat)bottom andNear:(GLfloat)near
Discussion
Linear matrices cannot support orthographic projection. This method throws an assertion exception.
Declared In
CC3LinearMatrix.h
populateOrthoFromFrustumLeft:andRight:andTop:andBottom:andNear:andFar:
Populates this matrix as a parallel orthographic matrix with the specified frustum dimensions.
- (void)populateOrthoFromFrustumLeft:(GLfloat)left andRight:(GLfloat)right andTop:(GLfloat)top andBottom:(GLfloat)bottom andNear:(GLfloat)near andFar:(GLfloat)far
Discussion
Linear matrices cannot support orthographic projection. This method throws an assertion exception.
Declared In
CC3LinearMatrix.h
populateToLookAt:withEyeAt:withUp:
Populates this matrix so that it will transform a vector between the targetLocation and the eyeLocation to point along the negative Z-axis, and transform the specified upDirection to the positive Y-axis.
- (void)populateToLookAt:(CC3Vector)targetLocation withEyeAt:(CC3Vector)eyeLocation withUp:(CC3Vector)upDirection
Discussion
This transform works in the direction from model-space to view-space, and therefore includes an implied inversion relative to the directToward:withUp: method. When applied to the camera, this has the effect of locating the camera at the eyeLocation and pointing it at the targetLocation, while orienting it so that ‘up’ appears to be in the upDirection, from the viewer’s perspective.
Since linear matrices are unaffected by translation, this matrix will be populated to look in the correct direction as if the eye were at the specified coordinate, but will not be looking at the target location, as the matrix cannot be translated to the location of the eye. In order to bring the targetLocation into view, this matrix must be applied to a matrix that can support translation to the eyeLocation.
Declared In
CC3LinearMatrix.h
transformHomogeneousVector:
Transforms the specified homogeneous vector using this matrix, and returns the transformed vector.
- (CC3Vector4)transformHomogeneousVector:(CC3Vector4)aVector
Discussion
Since linear matrices have no translation component, the vector is transformed as a direction, regardless of the W component of the homogeneous vector. However, the W component of the returned vector will be the same as that of the incoming vector.
This matrix and the original specified homogeneous vector remain unchanged.
Declared In
CC3LinearMatrix.h
transformLocation:
Transforms the specified location vector using this matrix, and returns the transformed location.
- (CC3Vector)transformLocation:(CC3Vector)aLocation
Discussion
Since linear matrices have no translation component, the location is transformed as if it were a direction.
This matrix and the original specified location remain unchanged.
Declared In
CC3LinearMatrix.h