ProtoTwin API
    Preparing search index...

    Class Quat

    Immutable quaternion.

    Unit quaternions are used to represent rotations. Quaternions are difficult to visualize and generally shouldn't be constructed directly from their constituent components. Instead, you should use the various static construction functions.

    Implements

    Index

    Constructors

    • Constructor.

      Parameters

      • x: number

        The x component.

      • y: number

        The y component.

      • z: number

        The z component.

      • w: number

        The w component.

      Returns Quat

    Properties

    w: number

    The w component of the quaternion.

    x: number

    The x component of the quaternion.

    y: number

    The y component of the quaternion.

    z: number

    The z component of the quaternion.

    Accessors

    • get xaxis(): Vec3

      The x-axis of the frame represented by the quaternion.

      Returns Vec3

    • get yaxis(): Vec3

      The y-axis of the frame represented by the quaternion.

      Returns Vec3

    • get zaxis(): Vec3

      The z-axis of the frame represented by the quaternion.

      Returns Vec3

    • get identity(): Quat

      The identity rotation.

      Returns Quat

    Methods

    • Converts the quaternion to a string.

      Returns string

      The string representation of the quaternion.

    • Creates a unit quaternion that represents that shortest-arc rotation from one vector to another.

      Parameters

      • from: IVec3

        The source unit vector.

      • to: IVec3

        The target unit vector.

      Returns Quat

      The minimal rotation unit quaternion.

    • Calculates the rotation angle of the specified quaternion.

      Parameters

      • value: IQuat

        The quaternion.

      Returns number

      The angle of rotation for the quaternion.

    • Creates a unit quaternion that rotates the specified angle about the specified axis.

      Parameters

      • axis: IVec3

        The rotation axis (unit vector).

      • angle: number

        The rotation angle (radians).

      Returns Quat

      The corresponding unit quaternion.

    • Composes (multiplies) two quaternions together.

      Parameters

      • lhs: IQuat

        The left-hand side quaternion.

      • rhs: IQuat

        The right-hand side quaternion.

      Returns Quat

      The result of composing the two quaternions.

    • Creates a copy of the provided quaternion.

      Parameters

      • src: IQuat

        The quaternion to be copied.

      Returns Quat

      The created copy.

    • Calculates the shortest unsigned angle between two unit quaternions.

      Parameters

      • from: IQuat

        The first unit quaternion.

      • to: IQuat

        The second unit quaternion.

      Returns number

      The shortest unsigned angle (radians).

    • Calculates the dot product of two quaternions.

      Parameters

      • lhs: IQuat

        The first quaternion.

      • rhs: IQuat

        The second quaternion.

      Returns number

      The dot product.

    • Determines whether two quaternions are exactly equal.

      Parameters

      • lhs: IQuat

        The first quaternion.

      • rhs: IQuat

        The second quaternion.

      Returns boolean

      True if the two quaternions are exactly equal, false otherwise.

    • Creates a unit quaternion that is oriented with the specified unit axes.

      Parameters

      • xaxis: IVec3

        The x-axis for the quaternion.

      • yaxis: IVec3

        The y-axis for the quaternion.

      • zaxis: IVec3

        The x-axis for the quaternion.

      Returns Quat

      The corresponding unit quaternion.

      The axes provided must be orthonormal to each other.

    • Creates a unit quaternion from the specified Euler angles.

      Parameters

      • xyz: IVec3

        The Euler angles (radians).

      Returns Quat

      The corresponding unit quaternion.

      This function will create a quaternion that rotates x radians about the x-axis then y radians about the y-axis and finally z radians about the z-axis.

    • Creates a quaternion that is the inverse of the specified quaternion.

      Parameters

      • value: IQuat

        The quaternion.

      Returns Quat

      The inverse quaternion.

    • Linearly interpolates between two unit quaternions.

      Parameters

      • lhs: IQuat

        The start unit quaternion.

      • rhs: IQuat

        The end unit quaternion.

      • weight: number

        The interpolation fraction between the two quaternions.

      Returns Quat

      The interpolated quaternion.

    • Creates a unit quaternion that is oriented such that its z-axis points in the specified forward direction.

      Parameters

      • forward: IVec3

        The forward direction (unit vector).

      • up: IVec3

        The unit vector the hints at which direction is up.

      Returns Quat

      The corresponding unit quaternion.

      The up direction specifes a hint. The y-axis for the frame represented by the returned unit quaternion may not equal the provided up direction. The forward and up direction vectors must not be colinear.

    • Creates a unit quaternion that is oriented such that its z-axis points in the direction of the target point from the source point.

      Parameters

      • target: IVec3

        The target point to look at.

      • source: IVec3

        The source point to look from.

      • up: IVec3

        The unit vector the hints at which direction is up.

      Returns Quat

      The corresponding unit quaternion.

      The up direction specifes a hint. The y-axis for the frame represented by the returned unit quaternion may not equal the provided up direction. The target and source points must not be coincident. The direction from the source point to the target point must not be colinear to the up direction vector.

    • Creates a quaternion that is the negation of the specified quaternion.

      Parameters

      • value: IQuat

        The quaternion.

      Returns Quat

      The negated quaternion.

    • Calculates the magnitude of the specified quaternion.

      Parameters

      • value: IQuat

        The quaternion.

      Returns number

      The magnitude.

    • Creates a unit length quaternion from the specified quaternion.

      Parameters

      • value: IQuat

        The quaternion.

      Returns Quat

      The normalized (unit) quaternion.

    • Calculates the squared magnitude of the specified quaternion.

      Parameters

      • value: IQuat

        The quaternion.

      Returns number

      The squared magnitude.

    • Determines whether two quaternions are not exactly equal.

      Parameters

      • lhs: IQuat

        The first quaternion.

      • rhs: IQuat

        The second quaternion.

      Returns boolean

      True if the two quaternions are different, false otherwise.

    • Spherically interpolates between two unit quaternions.

      Parameters

      • lhs: IQuat

        The start unit quaternion.

      • rhs: IQuat

        The end unit quaternion.

      • weight: number

        The interpolation fraction between the two quaternions.

      Returns Quat

      The interpolated quaternion.

    • Calculates the xyz Euler angles for a unit quaternion.

      Parameters

      • q: IQuat

        The unit quaternion.

      Returns Vec3

      The xyz Euler angles (radians).

    • Rotates the specified vector by the provided unit quaternion.

      Parameters

      • q: IQuat

        The unit quaternion.

      • v: IVec3

        The vector to be rotated.

      Returns Vec3

      The rotated vector.

    • Creates a unit quaternion that rotates the specified angle about the x-axis.

      Parameters

      • angle: number

        The rotation angle (radians).

      Returns Quat

      The corresponding unit quaternion.

    • Creates a unit quaternion that rotates the specified angle about the y-axis.

      Parameters

      • angle: number

        The rotation angle (radians).

      Returns Quat

      The corresponding unit quaternion.

    • Creates a unit quaternion that rotates the specified angle about the z-axis.

      Parameters

      • angle: number

        The rotation angle (radians).

      Returns Quat

      The corresponding unit quaternion.