UNPKG

ts-scikit

Version:

A scientific toolkit written in Typescript

110 lines (109 loc) 3.58 kB
import { Matrix44 } from './matrix44'; import { Vector3 } from './vector3'; import { Tuple4 } from './tuple4'; /** * A quaternion. * * Quaternions are vector-like objects of the form w + xi + yj + zk, where * w, x, y, and z are real numbers and i, j, and k are imaginary units. */ export declare class Quaternion extends Tuple4 { /** * Constructs a new quaternion from euler angles of rotation. * @param angleX the angle of rotation in the x-axis. * @param angleY the angle of rotation in the y-axis. * @param angleZ the angle of rotation in the z-axis. */ static FromEulerAngles(angleX: number, angleY: number, angleZ: number): Quaternion; /** * Constructs a new quaternion from a specified matrix. * @param mat the matrix. */ static FromMatrix(mat: Matrix44): Quaternion; /** * Constructs a copy of a specified quaternion. * @param q the quaternion. */ static FromQuaternion(q: Quaternion): Quaternion; /** * Constructs a new quaternion. * @param x the x-component. * @param y the y-component. * @param z the z-component. * @param w the w-component. */ constructor(x: number, y: number, z: number, w: number); /** * Gets the length of this quaternion, squared. * @returns the length of this quaternion, squared. */ get lengthSquared(): number; /** * Gets the length of this quaternion. * @returns the length of this quaternion. */ get length(): number; /** * Adds a specified quaternion to this quaternion. * @param q the quaternion to add. * @returns a reference to this quaternion, updated. */ plusEquals(q: Quaternion): this; /** * Returns the quaternion y = x + q for this quaternion x and specified quaternion q. * @param q the quaternion q. * @returns the quaternion y = x + q. */ plus(q: Quaternion): Quaternion; /** * Subtracts a specified quaternion from this quaternion. * @param q the quaternion to subtract. * @returns a reference to this quaternion, updated. */ minusEquals(q: Quaternion): this; /** * Returns the quaternion y = x - q for this quaternion x and specified quaternion q. * @param q the quaternion q. * @returns the quaternion y = x - q. */ minus(q: Quaternion): Quaternion; /** * Computes the multiplicative inverse with another quaternion. * @param q the quaternion. * @returns the multiplicative inverse. */ timesInverse(q: Quaternion): Quaternion; /** * Multiplies this quaternion by a specified factor. * @param q the multiplication factor. * @returns the result. */ times(q: Quaternion | Vector3 | number): (Quaternion | Vector3); /** * Returns the normalized version of this quaternion. * @returns this quaternion, normalized. */ normalize(): Quaternion; /** * Computes the dot product of this quaternion with a specified quaternion. * @param q the quaternion. * @returns the dot product. */ dot(q: Quaternion): number; /** * Returns this quaternion as a vector in the Euler space. * @returns this quaternion as an Euler vector. */ toEuler(): Vector3; /** * Returns this quaternion as a matrix. * @returns the matrix. */ toMatrix(): Matrix44; /** * Returns this quaternion as a rotational matrix. * @returns the rotational matrix. */ toRotationMatrix(): Matrix44; private rotateVector; }