import * as quat from '../glmatrix/quat'; import type Matrix3 from './Matrix3'; import type Matrix4 from './Matrix4'; import Vector3, { RotateOrder } from './Vector3'; declare class Quaternion { /** * Storage of Quaternion, read and write of x, y, z, w will change the values in array * All methods also operate on the array instead of x, y, z, w components */ array: quat.QuatArray; constructor(x?: number, y?: number, z?: number, w?: number); get x(): number; set x(value: number); get y(): number; set y(value: number); get z(): number; set z(value: number); get w(): number; set w(value: number); /** * Add b to self * @param b */ add(b: Quaternion): this; /** * Calculate the w component from x, y, z component */ calculateW(): this; /** * Set x, y and z components * @param x * @param y * @param z * @param w */ set(x: number, y: number, z: number, w: number): this; /** * Set x, y, z and w components from array * @param arr */ setArray(arr: quat.QuatArray): this; /** * Clone a new Quaternion */ clone(): Quaternion; /** * Calculates the conjugate of self If the quaternion is normalized, * this function is faster than invert and produces the same result. * */ conjugate(): this; /** * Copy from b * @param b */ copy(b: Quaternion): this; /** * Dot product of self and b * @param b */ dot(b: Quaternion): number; /** * Set from the given 3x3 rotation matrix * @param m */ fromMat3(m: Matrix3): this; /** * Set from the given 4x4 rotation matrix * The 4th column and 4th row will be droped * @param m */ fromMat4(m: Matrix4): this; /** * Set to identity quaternion */ identity(): this; /** * Invert self */ invert(): this; /** * Alias of length */ len(): number; /** * Calculate the length */ length(): number; /** * Linear interpolation between a and b * @param a * @param b * @param t */ lerp(a: Quaternion, b: Quaternion, t: number): this; /** * Alias for multiply * @param b */ mul(b: Quaternion): this; /** * Alias for multiplyLeft * @param a */ mulLeft(a: Quaternion): this; /** * Mutiply self and b * @param b */ multiply(b: Quaternion): this; /** * Mutiply a and self * Quaternion mutiply is not commutative, so the result of mutiplyLeft is different with multiply. * @param a */ multiplyLeft(a: Quaternion): this; /** * Normalize self */ normalize(): this; /** * Rotate self by a given radian about X axis * @param rad */ rotateX(rad: number): this; /** * Rotate self by a given radian about Y axis * @param rad */ rotateY(rad: number): this; /** * Rotate self by a given radian about Z axis * @param rad */ rotateZ(rad: number): this; /** * Sets self to represent the shortest rotation from Vector3 a to Vector3 b. * a and b needs to be normalized * @param a * @param b */ rotationTo(a: Vector3, b: Vector3): this; /** * Sets self with values corresponding to the given axes * @param view * @param right * @param up */ setAxes(view: Vector3, right: Vector3, up: Vector3): this; /** * Sets self with a rotation axis and rotation angle * @param axis * @param rad */ setAxisAngle(axis: Vector3, rad: number): this; /** * Perform spherical linear interpolation between a and b * @param a * @param b * @param t */ slerp(a: Quaternion, b: Quaternion, t: number): this; /** * Alias for squaredLength */ sqrLen(): number; /** * Squared length of self */ squaredLength(): number; /** * Set from euler * @param v * @param order */ fromEuler(v: Vector3, order: RotateOrder): void; toString(): string; toArray(): quat.QuatArray; /** * @param out * @param a * @param b */ static add(out: Quaternion, a: Quaternion, b: Quaternion): Quaternion; /** * @param out * @param x * @param y * @param z * @param w */ static set(out: Quaternion, x: number, y: number, z: number, w: number): void; /** * @param out * @param b */ static copy(out: Quaternion, b: Quaternion): Quaternion; /** * @param out * @param a */ static calculateW(out: Quaternion, a: Quaternion): Quaternion; /** * @param out * @param a */ static conjugate(out: Quaternion, a: Quaternion): Quaternion; /** * @param out */ static identity(out: Quaternion): Quaternion; /** * @param out * @param a */ static invert(out: Quaternion, a: Quaternion): Quaternion; /** * @param a * @param b */ static dot(a: Quaternion, b: Quaternion): number; /** * @param a */ static len(a: Quaternion): number; /** * @param out * @param a * @param b * @param t */ static lerp(out: Quaternion, a: Quaternion, b: Quaternion, t: number): Quaternion; /** * @param out * @param a * @param b * @param t */ static slerp(out: Quaternion, a: Quaternion, b: Quaternion, t: number): Quaternion; /** * @param out * @param a * @param b */ static mul(out: Quaternion, a: Quaternion, b: Quaternion): Quaternion; /** * @function * @param out * @param a * @param b */ static multiply: typeof Quaternion.mul; /** * @param out * @param a * @param rad */ static rotateX(out: Quaternion, a: Quaternion, rad: number): Quaternion; /** * @param out * @param a * @param rad */ static rotateY(out: Quaternion, a: Quaternion, rad: number): Quaternion; /** * @param out * @param a * @param rad */ static rotateZ(out: Quaternion, a: Quaternion, rad: number): Quaternion; /** * @param out * @param axis * @param rad */ static setAxisAngle(out: Quaternion, axis: Vector3, rad: number): Quaternion; /** * @param out * @param a */ static normalize(out: Quaternion, a: Quaternion): Quaternion; /** * @param a */ static sqrLen(a: Quaternion): number; /** * @function * @param a */ static squaredLength: typeof Quaternion.sqrLen; /** * @param out * @param m */ static fromMat3(out: Quaternion, m: Matrix3): Quaternion; /** * @param out * @param view * @param right * @param up */ static setAxes(out: Quaternion, view: Vector3, right: Vector3, up: Vector3): Quaternion; /** * @param out * @param a * @param b */ static rotationTo(out: Quaternion, a: Vector3, b: Vector3): Quaternion; /** * Set quaternion from euler * @param out * @param v * @param order */ static fromEuler(out: Quaternion, v: Vector3, order: RotateOrder): void; } export default Quaternion;