Menu - Top - Home - Donate to Me

H3DU.Transform

Back to documentation index.

H3DU.Transform()

A class offering a convenient way to set a transformation from one coordinate system to another.

Methods

H3DU.Transform#copy()

Makes a copy of this transform. The copied object will have its own version of the rotation, scale, position, and matrix data.

Return Value

A copy of this transform. (Type: H3DU.Transform)

H3DU.Transform#getMatrix()

Gets the transformation matrix used by an object. Depending on the state of this transform, will return either:

Return Value

Return value. (Type: Array.<number>)

H3DU.Transform#getPosition()

Returns a copy of a three-element array giving the X, Y, and Z coordinates of the position of an object relative to its original position.

Return Value

Return value. (Type: Array.<number>)

H3DU.Transform#getQuaternion()

Returns a copy of the rotation of an object in the form of a quaternion.

Return Value

Return value. (Type: Array.<number>)

H3DU.Transform#getScale()

Returns a copy of a three-element array giving the scaling for an object's width, height, and depth, respectively. For each component, 1 means no scaling.

Return Value

Return value. (Type: Array.<number>)

H3DU.Transform#isIdentity()

Returns whether this transform is the identity transform.

Return Value

Return value. (Type: boolean)

H3DU.Transform#movePosition(x, y, z)

Moves the relative position of an object from its original position. Has no effect if a matrix was defined with H3DU.Transform#setMatrix and the transform wasn't reset yet with H3DU.Transform#resetTransform.

Parameters

Return Value

This object. (Type: H3DU.Transform)

H3DU.Transform#multOrientation(angle, v, vy, vz)

Deprecated: Use H3DU.Transform#multRotation instead. This method's name is inaccurate because orientations are not rotations.

Combines an object's current rotation with another rotation in the form of an angle and an axis of rotation. The combined rotation will have the same effect as the new rotation followed by the existing rotation. Has no effect if a matrix was defined with H3DU.Transform#setMatrix and the transform wasn't reset yet with H3DU.Transform#resetTransform.

Parameters

Return Value

This object. (Type: H3DU.Transform)

H3DU.Transform#multQuaternion(quat)

Combines an object's current rotation with another rotation described by a quaternion (a 4-element array for describing 3D rotations). The combined rotation will have the same effect as the new rotation followed by the existing rotation. Has no effect if a matrix was defined with H3DU.Transform#setMatrix and the transform wasn't reset yet with H3DU.Transform#resetTransform.

Parameters

Return Value

This object. (Type: H3DU.Transform)

Example

// Combine an object's rotation with a rotation 20 degrees about the X axis
transform.multQuaternion(H3DU.Math.quatFromAxisAngle(20,1,0,0));
// Combine an object's rotation with identity
transform.multQuaternion(H3DU.Math.quatIdentity());
// Combine an object's rotation with 30 degree pitch multiplied
// by 40 degree roll
transform.multQuaternion(H3DU.Math.quatFromTaitBryan(30,0,40));

H3DU.Transform#multRotation(angle, v, vy, vz)

Combines an object's current rotation with another rotation in the form of an angle and an axis of rotation. The combined rotation will have the same effect as the new rotation followed by the existing rotation. Has no effect if a matrix was defined with H3DU.Transform#setMatrix and the transform wasn't reset yet with H3DU.Transform#resetTransform.

Parameters

Return Value

This object. (Type: H3DU.Transform)

H3DU.Transform#reset()

Resets this transform to the untransformed state.

Return Value

This object. (Type: H3DU.Transform)

H3DU.Transform#resetTransform()

Deprecated: Use the "reset" method instead.

Resets this transform to the untransformed state.

Return Value

This object. (Type: H3DU.Transform)

H3DU.Transform#setMatrix(value)

Sets this transform's transformation matrix. This method will set the position, rotation, and scale properties accordingly to the matrix given.

Parameters

Return Value

This object. (Type: H3DU.Transform)

H3DU.Transform#setOrientation(angle, v, vy, vz)

Deprecated: Use H3DU.Transform#setRotation instead. This method's name is inaccurate because orientations are not rotations.

Sets this transform's rotation in the form of an angle and an axis of rotation. Has no effect if a matrix was defined with H3DU.Transform#setMatrix and the transform wasn't reset yet with H3DU.Transform#resetTransform.

Parameters

Return Value

This object. (Type: H3DU.Transform)

H3DU.Transform#setPosition(x, y, z)

Sets the relative position of an object from its original position. Has no effect if a matrix was defined with H3DU.Transform#setMatrix and the transform wasn't reset yet with H3DU.Transform#resetTransform.

Parameters

Return Value

This object. (Type: H3DU.Transform)

H3DU.Transform#setQuaternion(quat)

Sets this transform's rotation in the form of a quaternion (a 4-element array for describing 3D rotations). Has no effect if a matrix was defined with H3DU.Transform#setMatrix and the transform wasn't reset yet with H3DU.Transform#resetTransform.

Parameters

Return Value

This object. (Type: H3DU.Transform)

Example

// Set an object's rotation to 30 degrees about the X axis
transform.setQuaternion(H3DU.Math.quatFromAxisAngle(20,1,0,0));
// Set an object's rotation to identity (the object isn't transformed)
transform.setQuaternion(H3DU.Math.quatIdentity());
// Set an object's rotation to 30 degree pitch multiplied
// by 40 degree roll
transform.setQuaternion(H3DU.Math.quatFromTaitBryan(30,0,40));

H3DU.Transform#setRotation(angle, v, vy, vz)

Sets this transform's rotation in the form of an angle and an axis of rotation. Has no effect if a matrix was defined with H3DU.Transform#setMatrix and the transform wasn't reset yet with H3DU.Transform#resetTransform.

Parameters

Return Value

This object. (Type: H3DU.Transform)

H3DU.Transform#setScale(x, y, z)

Sets the scale of an object relative to its original size. Has no effect if a matrix was defined with H3DU.Transform#setMatrix and the transform wasn't reset yet with H3DU.Transform#resetTransform.

Parameters

Return Value

This object. (Type: H3DU.Transform)

Back to documentation index.