/** * @license * Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ import { Mat3Array, QuatArray, Vec3Array } from './common'; import * as vec4 from './vec4'; export type { QuatArray }; /** * Creates a new identity quat * * @returns a new quaternion */ export declare function create(): QuatArray; /** * Sets a quaternion to represent the shortest rotation from one * vector to another. * * Both vectors are assumed to be unit length. * * @param out the receiving quaternion. * @param a the initial vector * @param b the destination vector * @returns out */ export declare const rotationTo: (out: QuatArray, a: Vec3Array, b: Vec3Array) => vec4.Vec4Array; /** * Sets the specified quaternion with values corresponding to the given * axes. Each axis is a vec3 and is expected to be unit length and * perpendicular to all other specified axes. * * @param view the vector representing the viewing direction * @param right the vector representing the local "right" direction * @param up the vector representing the local "up" direction * @returns out */ export declare const setAxes: (out: QuatArray, view: Vec3Array, right: Vec3Array, up: Vec3Array) => vec4.Vec4Array; /** * Creates a new quat initialized with values from an existing quaternion * * @param a quaternion to clone * @returns a new quaternion * @function */ export declare const clone: typeof vec4.clone; /** * Creates a new quat initialized with the given values * * @param x X component * @param y Y component * @param z Z component * @param w W component * @returns a new quaternion * @function */ export declare const fromValues: typeof vec4.fromValues; /** * Copy the values from one quat to another * * @param out the receiving quaternion * @param a the source quaternion * @returns out * @function */ export declare const copy: typeof vec4.copy; /** * Set the components of a quat to the given values * * @param out the receiving quaternion * @param x X component * @param y Y component * @param z Z component * @param w W component * @returns out * @function */ export declare const set: typeof vec4.set; /** * Set a quat to the identity quaternion * * @param out the receiving quaternion * @returns out */ export declare function identity(out: number[]): number[]; /** * Sets a quat from the given angle and rotation axis, * then returns it. * * @param out the receiving quaternion * @param axis the axis around which to rotate * @param rad the angle in radians * @returns out **/ export declare function setAxisAngle(out: QuatArray, axis: Vec3Array, rad: number): QuatArray; /** * Adds two quat's * * @param out the receiving quaternion * @param a the first operand * @param b the second operand * @returns out * @function */ export declare const add: typeof vec4.add; /** * Multiplies two quat's * * @param out the receiving quaternion * @param a the first operand * @param b the second operand * @returns out */ export declare function multiply(out: QuatArray, a: QuatArray, b: QuatArray): QuatArray; /** * Alias for {@link quat.multiply} * @function */ export declare const mul: typeof multiply; /** * Scales a quat by a scalar number * * @param out the receiving vector * @param a the vector to scale * @param b amount to scale the vector by * @returns out * @function */ export declare const scale: typeof vec4.scale; /** * Rotates a quaternion by the given angle about the X axis * * @param out quat receiving operation result * @param a quat to rotate * @param rad angle (in radians) to rotate * @returns out */ export declare function rotateX(out: QuatArray, a: QuatArray, rad: number): QuatArray; /** * Rotates a quaternion by the given angle about the Y axis * * @param out quat receiving operation result * @param a quat to rotate * @param rad angle (in radians) to rotate * @returns out */ export declare function rotateY(out: QuatArray, a: QuatArray, rad: number): QuatArray; /** * Rotates a quaternion by the given angle about the Z axis * * @param out quat receiving operation result * @param a quat to rotate * @param rad angle (in radians) to rotate * @returns out */ export declare function rotateZ(out: QuatArray, a: QuatArray, rad: number): QuatArray; /** * Calculates the W component of a quat from the X, Y, and Z components. * Assumes that quaternion is 1 unit in length. * Any existing W component will be ignored. * * @param out the receiving quaternion * @param a quat to calculate W component of * @returns out */ export declare function calculateW(out: QuatArray, a: QuatArray): QuatArray; /** * Calculates the dot product of two quat's * * @param a the first operand * @param b the second operand * @returns dot product of a and b * @function */ export declare const dot: typeof vec4.dot; /** * Performs a linear interpolation between two quat's * * @param out the receiving quaternion * @param a the first operand * @param b the second operand * @param t interpolation amount between the two inputs * @returns out * @function */ export declare const lerp: typeof vec4.lerp; /** * Performs a spherical linear interpolation between two quat * * @param out the receiving quaternion * @param a the first operand * @param b the second operand * @param t interpolation amount between the two inputs * @returns out */ export declare function slerp(out: QuatArray, a: QuatArray, b: QuatArray, t: number): QuatArray; /** * Calculates the inverse of a quat * * @param out the receiving quaternion * @param a quat to calculate inverse of * @returns out */ export declare function invert(out: QuatArray, a: QuatArray): QuatArray; /** * Calculates the conjugate of a quat * If the quaternion is normalized, this function is faster than quat.inverse and produces the same result. * * @param out the receiving quaternion * @param a quat to calculate conjugate of * @returns out */ export declare function conjugate(out: QuatArray, a: QuatArray): QuatArray; /** * Calculates the length of a quat * * @param a vector to calculate length of * @returns length of a * @function */ export declare const length: typeof vec4.length; /** * Alias for {@link quat.length} * @function */ export declare const len: typeof vec4.length; /** * Calculates the squared length of a quat * * @param a vector to calculate squared length of * @returns squared length of a * @function */ export declare const squaredLength: typeof vec4.squaredLength; /** * Alias for {@link quat.squaredLength} * @function */ export declare const sqrLen: typeof vec4.squaredLength; /** * Normalize a quat * * @param out the receiving quaternion * @param a quaternion to normalize * @returns out * @function */ export declare const normalize: typeof vec4.normalize; /** * Creates a quaternion from the given 3x3 rotation matrix. * * NOTE: The resultant quaternion is not normalized, so you should be sure * to renormalize the quaternion yourself where necessary. * * @param out the receiving quaternion * @param m rotation matrix * @returns out * @function */ export declare function fromMat3(out: QuatArray, m: Mat3Array): QuatArray;