import * as Common from './common'; import type { mat3 } from './mat3'; import { mat4 } from './mat4'; import { vec3 } from './vec3'; import { vec4 } from './vec4'; /** * Represents rotation in 3D space with the quaternion format XYZW. * @category Types */ export type quat = readonly [x: number, y: number, z: number, w: number]; /** * Functions for {@link quat}, a format for representing rotation in 3D space. * @category Modules */ export declare namespace quat { /** * Mutable version of {@link quat} * @category Types */ type Mutable = [x: number, y: number, z: number, w: number]; /** * Creates a new quaternion from given elements * @category Generators */ function of(x: number, y: number, z: number, w: number): quat; /** * Creates a mutable clone of given quat * @category Generators */ function clone(a: quat): Mutable; /** * Constrain each component to lie between min and max * @see https://thebookofshaders.com/glossary/?search=clamp */ function clamp(q: quat, min: number, max: number): quat; /** * Clamps each component to [0, 1] */ function clamp01(q: quat): quat; /** * Clamps each component to [-1, 1] */ function clamp11(q: quat): quat; /** * The identity quaternion. * @category Constants * * @shorthands * - {@link id} * - {@link ident} */ const identity: quat; /** * Alias for {@link identity} * @category Shorthands */ const I: quat; /** * Alias for {@link identity} * @category Shorthands */ const id: quat; /** * Alias for {@link identity} * @category Shorthands */ const ident: quat; /** * The zero quaternion. * @category Constants */ const zero: quat; /** * Sets a quat from the given angle and rotation axis, * then returns it. * @category Generators * @param axis the axis around which to rotate * @param deg the angle in degrees **/ function fromAxisAngle(axis: vec3, deg: number): quat; /** * Gets the rotation axis and angle for a given * quaternion. If a quaternion is created with * fromAxisAngle, this method will return the same * values as provided in the original parameter list * OR functionally equivalent values. * Example: The quaternion formed by axis [0, 0, 1] and * angle -90 is the same as the quaternion formed by * [0, 0, 1] and 270. This method favors the latter. * * @param q Quaternion to be decomposed */ function axisAngle(q: quat): { axis: vec3; deg: number; }; /** * Gets the angular distance between two unit quaternions * * @param a Origin unit quaternion * @param b Destination unit quaternion * @return Angle, in degrees, between the two quaternions */ function angle(a: quat, b: quat): number; /** * Multiplies given quat's * * @param a the first operand * @param b the second operand * * @shorthands * - {@link mul} */ function multiply(...qs: quat[]): quat; /** * Alias for {@link multiply} * @category Shorthands */ const mul: typeof multiply; /** * Rotates a quaternion by the given angle about the X axis * * @param a quat to rotate * @param deg angle to rotate, in degrees */ function rotateX(a: quat, deg: number): quat; /** * Rotates a quaternion by the given angle about the Y axis * * @param a quat to rotate * @param deg angle to rotate, in degrees */ function rotateY(a: quat, deg: number): quat; /** * Rotates a quaternion by the given angle about the Z axis * * @param a quat to rotate * @param deg angle (in degrees) to rotate */ function rotateZ(a: quat, deg: number): quat; /** * 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. */ function calculateW(q: quat): quat; /** * Calculate the exponential of a unit quaternion. */ function exp(q: quat): quat; /** * Calculate the natural logarithm of a unit quaternion. */ function ln(a: quat): quat; /** * Calculate the scalar power of a unit quaternion. */ function pow(a: quat, b: number): quat; /** * Performs a spherical linear interpolation between two quat * * @param a the first operand * @param b the second operand * @param t interpolation amount, in the range [0-1], between the two inputs */ function slerp(a: quat, b: quat, t: number): quat; /** * Calculates the inverse of a quat */ function invert(q: quat): quat; /** * Calculates the conjugate of a quat * If the quaternion is normalized, this function is faster than quat.inverse and produces the same result. */ function conjugate(a: quat): quat; /** * 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. * @category Generators */ function fromMat3(m: mat3): quat; /** * Creates a quaternion from the given 4x4 affine matrix. The translation portion of the matrix is ignored. Same as mat4. Alias for {@link mat4.getRotation}. */ const fromMat4: typeof mat4.getRotation; /** * Creates a quaternion from a normalized direction vector and an up vector. * Equivalent to GLM's `glm::quatLookAt`. * * @param direction Normalized direction vector (forward) * @param up Up vector, default is vec3.unitY * @category Generators */ function lookAt(direction: vec3, up?: vec3): quat; /** * Creates a quaternion from the given euler angle x, y, z using the provided intrinsic order for the conversion. * * @param deg Angles to rotate around X, Y, Z axes in degree. * @param order Intrinsic order for conversion, default is zyx. * @category Generators */ function fromEuler(deg: vec3, order?: Common.AngleOrder): number[]; /** * Extracts Euler angles from a quaternion. This is the inverse of {@link fromEuler}. * Equivalent to GLM's `glm::eulerAngles`. * * @param q The quaternion to extract Euler angles from * @param order Intrinsic order for conversion, default is zyx * @returns Euler angles in degrees as vec3 [x, y, z] */ function toEuler(q: quat, order?: Common.AngleOrder): vec3; /** * Performs a normalized linear interpolation (nlerp) between two quaternions. * Faster than {@link slerp} and sufficient for small rotation differences. * * @param a the first operand * @param b the second operand * @param t interpolation amount, in the range [0-1], between the two inputs */ function lerp(a: quat, b: quat, t: number): quat; /** * Adds given quat's */ const add: (a: quat, b: quat) => quat; /** * Scales a quat by a scalar number */ const scale: (a: quat, b: number) => quat; /** * Calculates the dot product of two quat's */ const dot: (a: quat, b: quat) => number; /** * Calculates the length of a quat * * @param a vector to calculate length of * @returns length of a * * @shorthands * - {@link len} */ const length: typeof vec4.length; /** * Alias for {@link length} * @category Shorthands */ 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 * * @shorthands * - {@link sqrLen} */ const squaredLength: typeof vec4.squaredLength; /** * Alias for {@link squaredLength} * @category Shorthands */ const sqrLen: typeof vec4.squaredLength; /** * Normalize a quat * * @param a quaternion to normalize */ const normalize: typeof vec4.normalize; /** * Returns whether or not the quaternions have exactly the same elements in the same position (when compared with `===`) * * @shorthands * - {@link eq} */ const exactEquals: typeof vec4.exactEquals; /** * Alias for {@link exactEquals} * @category Shorthands */ const eq: typeof vec4.exactEquals; /** * Returns whether or not the quaternions point approximately to the same direction. Both quaternions are assumed to be unit length. * * @shorthands * - {@link approx} * - {@link equals} */ function approxEquals(a: quat, b: quat): boolean; /** * Alias for {@link approxEquals} * @category Shorthands */ const approx: typeof approxEquals; /** * Alias for {@link approxEquals}. This is provided for compatibility with gl-matrix. * @category Shorthands * @deprecated Use {@link approxEquals} instead */ const equals: typeof approxEquals; /** * Sets a quaternion to represent the shortest rotation from one * vector to another. * * Both vectors are assumed to be unit length. * * @param a the initial vector * @param b the destination vector * @category Generators */ const rotationTo: (a: vec3, b: vec3) => quat; /** * Performs a spherical linear interpolation with two control points * * @param a the first operand * @param b the second operand * @param c the third operand * @param d the fourth operand * @param t interpolation amount, in the range [0-1], between the two inputs */ function sqlerp(a: quat, b: quat, c: quat, d: quat, t: number): quat; /** * 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 */ function setAxes(view: vec3, right: vec3, up: vec3): quat; } //# sourceMappingURL=quat.d.ts.map