v2.0.2
Instance Methods | Class Methods | Properties | List of all members
CC3MutableRotator Class Reference

#import <CC3Rotator.h>

Inheritance diagram for CC3MutableRotator:
Inheritance graph
[legend]

Instance Methods

(id) - initOnRotationMatrix:
 
(void) - markRotationDirty
 
(void) - orthonormalize
 
(void) - rotateBy:
 
(void) - rotateByAngle:aroundAxis:
 
(void) - rotateByQuaternion:
 
- Instance Methods inherited from CC3Rotator
(void) - applyRotationTo:
 
(BOOL) - clearIfTarget:
 
(NSString *) - fullDescription
 
(void) - populateFrom:
 
(CC3Vector- transformDirection:
 

Class Methods

(GLubyte) + autoOrthonormalizeCount
 
(id) + rotatorOnRotationMatrix:
 
(void) + setAutoOrthonormalizeCount:
 
- Class Methods inherited from CC3Rotator
(id) + rotator
 

Properties

BOOL isRotationDirty
 
CC3Quaternion quaternion
 
CC3Vector rotation
 
GLfloat rotationAngle
 
CC3Vector rotationAxis
 
CC3MatrixrotationMatrix
 
- Properties inherited from CC3Rotator
BOOL isDirectional
 
BOOL isMutable
 
BOOL isTargettable
 
BOOL isTrackingForBumpMapping
 
BOOL isTrackingTargetDirection
 
CC3Quaternion quaternion
 
CC3Vector rotation
 
GLfloat rotationAngle
 
CC3Vector rotationAxis
 
CC3MatrixrotationMatrix
 
BOOL shouldAutotargetCamera
 
BOOL shouldRotateToTargetLocation
 
BOOL shouldTrackTarget
 
BOOL shouldUpdateToTarget
 
CC3Nodetarget
 
CC3Vector targetLocation
 
CC3TargettingConstraint targettingConstraint
 

Detailed Description

CC3MutableRotator encapsulates the various mechanisms for specifiying rotation, and converts between them.

Rotations can be specified in any of the following methods:

The rotator maintains an internal rotationMatrix, separate from the node's globalTransformMatrix, and the rotator can use this rotationMatrix to convert between different rotational specifications. As such, the rotation of a node can be set using any one of the above specifications, and read back as any of the other specifications.

Method Documentation

+ (GLubyte) autoOrthonormalizeCount

Indicates how often the basis vectors of the underlying rotation matrix should be orthonormalized.

If this property is set to a value greater than zero, this rotator keeps track of how many times one of the rotateBy... family of methods of a CC3MutableRotator has been invoked. When that count reaches the value of this property, the orthonormalize method is invoked to orthonormalize the underlying matrix, and the count is set back to zero to start the cycle again. See the notes for the CC3MutableRotator orthonormalize method for a further discussion of orthonormalization.

If this property is set to zero, orthonormalization will not occur automatically. The application can invoke the orthonormalize method to cause the rotation matrix to be orthonormalized manually.

The initial value of this property is zero, indicating that orthonormalization will not occur automatically.

- (id) initOnRotationMatrix: (CC3Matrix *)  aMatrix

Initializes this instance to use the specified matrix as the rotationMatrix.

- (void) markRotationDirty

Indicates that the rotation matrix is dirty and needs to be recalculated.

This method is invoked automatically as needed. Usually the application never needs to invoke this method directly.

- (void) orthonormalize

When a large number of incremental rotations are applied to a rotator using the rotateBy...

family of methods, accumulated rounding errors can cause the basis vectors of the underlying rotation matrix to lose mutual orthogonality (no longer be orthogonal to each other), and to become individually unnormalized (no longer be unit vectors).

Although uncommon, it is possible for visible errors to creep into the rotation of this rotator, after many, many incremental rotations.

If this happens, you can invoke this method to orthonormalize the basis vectors of the underlying rotation matrix.

Instead of keeping track of when to invoke this method within the application, you can also set the class-side autoOrthonormalizeCount property to have this method automatically invoked periodically.

Upon completion of this method, each basis vector in the underlying matrix will be a unit vector that is orthagonal to the other two basis vectors in this matrix.

Error creep only appears through repeated use of the the rotateBy... family of methods. Error creep does not occur when the rotation is set explicitly through any of the rotation properties (rotation, quaternion, rotationAxis/rotationAngle, etc), as these properties populate the rotation matrix directly in orthonormal form each time then are set. Use of this method is not needed if rotations have been set directly using these properties, even when set many times.

This method uses using a Gram-Schmidt process to orthonormalize the basis vectors of the underlying rotation matrix. The Gram-Schmidt process is biased towards the basis vector chosen to start the calculation process. To minimize the effect of this, this implementation chooses a different basis vector to start the orthonormalization process each time this method is invoked, to average the bias across all basis vectors over time.

- (void) rotateBy: (CC3Vector aRotation

Rotates this rotator from its current state by the specified Euler angles in degrees.

- (void) rotateByAngle: (GLfloat)  anAngle
aroundAxis: (CC3Vector anAxis 

Rotates this rotator from its current state by rotating around the specified axis by the specified angle in degrees.

- (void) rotateByQuaternion: (CC3Quaternion aQuaternion

Rotates this rotator from its current state by the specified quaternion.

+ (id) rotatorOnRotationMatrix: (CC3Matrix *)  aMatrix

Allocates and initializes an autoreleased instance to use the specified matrix as the rotationMatrix.

+ (void) setAutoOrthonormalizeCount: (GLubyte)  aCount

Sets how often the basis vectors of the underlying rotation matrix should be orthonormalized.

If this property is set to a value greater than zero, this rotator keeps track of how many times one of the rotateBy... family of methods of a CC3MutableRotator has been invoked. When that count reaches the value of this property, the orthonormalize method is invoked to orthonormalize the underlying matrix, and the count is set back to zero to start the cycle again. See the notes for the CC3MutableRotator orthonormalize method for a further discussion of orthonormalization.

If this property is set to zero, orthonormalization will not occur automatically. The application can invoke the orthonormalize method to cause the rotation matrix to be orthonormalized manually.

The initial value of this property is zero, indicating that orthonormalization will not occur automatically.

Property Documentation

- (BOOL) isRotationDirty
readnonatomicassign

Indicates whether the rotation matrix is dirty and needs to be recalculated.

This property is automatically set to YES when one of the rotation properties or operations have been changed, and is reset to NO once the rotationMatrix has been recalculated.

- (CC3Quaternion) quaternion
readwritenonatomicassign

The rotation of the node in 3D space, relative to the parent of this node, expressed as a quaternion.

- (CC3Vector) rotation
readwritenonatomicassign

The rotational orientation of the node in 3D space, relative to the parent of the node.

This value contains three Euler angles, defining a rotation of this node around the X, Y and Z axes. Each angle is specified in degrees.

Rotation is performed in Y-X-Z order, which is the OpenGL default. Depending on the nature of the object you are trying to control, you can think of this order as yaw, then pitch, then roll, or heading, then inclination, then tilt,

When setting this value, each component is converted to modulo +/-360 degrees.

- (GLfloat) rotationAngle
readwritenonatomicassign

The angular rotation around the axis specified in the rotationAxis property.

When setting this value, it is converted to modulo +/-360 degrees.

- (CC3Vector) rotationAxis
readwritenonatomicassign

The axis of rotation of the node in 3D space, relative to the parent of this node, expressed as a directional vector.

This axis can be used in conjunction with the rotationAngle property to describe the rotation as a single angular rotation around an arbitrary axis.

- (CC3Matrix*) rotationMatrix
readwritenonatomicretain

The rotation matrix derived from the rotation or quaternion properties.

Rotation can be specified in terms of either of these properties, and read by either property, even if set by the other property. The matrix will reflect the rotational property most recently set.

The rotation matrix for each instance is local to the node and does not include rotational information about the node's ancestors.


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