Table Of Contents

Previous topic

util.BBox

Next topic

util.Vec3

This Page

util.Quaternion

Constructor

class util.Quaternion(x, y, z, w)
Arguments:
  • x
  • y
  • z
  • w – Quaternion should be assumed to only have .x, .y, .z, and .w.
:returns :
a quaternion object

Methods

add(rhs)
Arguments:
  • rhs
Returns:

quaternion sum of the two quaternions

angle()
Returns:The angle of rotation represented by this quaternion.
axis()
Returns:The axis of rotation represented by this quaternion.
clone()
Returns:a copy of this Quaternion.

Make a copy of this quaternion.

dot(rhs)
Arguments:
  • rhs
Returns:

Dot product of the two quaternions

equal(rhs)
param rhs:any type
returns:True if rhs is not a quaternion and x,y,z,and w fields
of this and rhs are identical. False otherwise.
rtype:bool
fromLookAt(direction, up)
Arguments:
  • direction – Vector that represents direction to look at.
  • up – Up direction of the quaternion.
Returns:

A quaternion constructed so that the -z axis (lookat direction) points in the same direction as the direction vector, with the up vector as close as possible to the given up vector.

inverse()
Returns:The inverse of this quaternion
isZero()
Returns:true if the quaternion is (near) zero/identity, i.e. that it represents no rotation, false otherwise
length()
Returns:The length of the quaternion
lengthSquared()
Returns:the length-squared of the quaternion
mul(rhs)
Arguments:
  • rhs
Returns:

The quaternion product of two quaternions

neg()
Returns:Returns the negation of the quaternion
normal()
Returns:The quaternion normal to this quaternion
scale(scalar)
Arguments:
  • scalar – by which to scale
Returns:

A quaternion scaled by the scalar parameter

sub(rhs)
Arguments:
  • rhs
Returns:

quaternion difference of the two quaternions

xAxis()
Returns:The x-axis of the quaternion as a Vec3
yAxis()
Returns:The y-axis of the quaternion as a Vec3
zAxis()
Returns:The z-axis of the quaternion as a Vec3

Attributes

identity

identity