Rotation

Return to Introduction  Previous page  Next page

A basic type used to represent a rotation that can be created with the 'new' keyword.

 

The constructor can be called without parameters, passed the x,y,z,w quaternion values of the rotation, or alternatively you can construct with a Rotation with 3 degree values representing rotations about the x,y,z axes in order.  You can also pass another Rotation object as a contructor to copy the initial values from.

 

Methods

 

normalize()

Normalizes the quaternion rotation (scales such that the components total 1)

reset()

Resets the value to the identity rotation (0,0,0,1).

rotateAxis(vaxis, angle)

Applies a rotation of 'angle' radians around the axis described by the Vector 'vaxis'.

 

Properties

 

x

Floating point value representing the x component of the rotation.

y

Floating point value representing the y component of the rotation.

z

Floating point value representing the z component of the rotation.

w

Floating point value representing the w component of the rotation.

eulerX

If the rotation was represented as a yaw, pitch and roll, this is the X axis rotation in degrees, or pitch.

eulerY

If the rotation was represented as a yaw, pitch and roll, this is the Y axis rotation in degrees, or yaw.

eulerZ

If the rotation was represented as a yaw, pitch and roll, this is the Z axis rotation in degrees, or roll.

 

Examples

 

var myRot = new Rotation(); // create a variable called myRot representing the identity rotation.

var myRot1 = new Rotation(0.0,0.0,0.0,1.0); // create a variable called myRot representing the specified quaternion.

var myRot2 = new Rotation(10.0,5.0,0); // create a Rotation that represents a 10 degree rotation about the x-axis, followed by a 5 degree rotation about the y-axis.

 

var myRot3 = new Rotation(myRot2); // create a Rotation with x,y,z,w values copied from myRot2.

 

object.rot.rotateAxis(new Vector(0.0,1.0,0.0), 45.0); // Rotate the current object 45 degrees about the axis (0,1,0).

 

Remarks

 

A 3D rotation is mathematically a 'Quaternion'.  They allow the storage of rotations without any of the problems associated with Euler angles.

 

See Also

 

Script Reference



Copyright ©2004 Worldweaver Ltd. DX Studio Home