123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- import { Euler } from './Euler';
- import { Vector3 } from './Vector3';
- import { Matrix4 } from './Matrix4';
- /**
- * Implementation of a quaternion. This is used for rotating things without incurring in the dreaded gimbal lock issue, amongst other advantages.
- *
- * @example
- * const quaternion = new THREE.Quaternion();
- * quaternion.setFromAxisAngle( new THREE.Vector3( 0, 1, 0 ), Math.PI / 2 );
- * const vector = new THREE.Vector3( 1, 0, 0 );
- * vector.applyQuaternion( quaternion );
- */
- export class Quaternion {
- /**
- * @param x x coordinate
- * @param y y coordinate
- * @param z z coordinate
- * @param w w coordinate
- */
- constructor( x?: number, y?: number, z?: number, w?: number );
- /**
- * @default 0
- */
- x: number;
- /**
- * @default 0
- */
- y: number;
- /**
- * @default 0
- */
- z: number;
- /**
- * @default 1
- */
- w: number;
- readonly isQuaternion: true;
- /**
- * Sets values of this quaternion.
- */
- set( x: number, y: number, z: number, w: number ): Quaternion;
- /**
- * Clones this quaternion.
- */
- clone(): Quaternion;
- /**
- * Copies values of q to this quaternion.
- */
- copy( q: Quaternion ): this;
- /**
- * Sets this quaternion from rotation specified by Euler angles.
- */
- setFromEuler( euler: Euler ): Quaternion;
- /**
- * Sets this quaternion from rotation specified by axis and angle.
- * Adapted from http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm.
- * Axis have to be normalized, angle is in radians.
- */
- setFromAxisAngle( axis: Vector3, angle: number ): Quaternion;
- /**
- * Sets this quaternion from rotation component of m. Adapted from http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm.
- */
- setFromRotationMatrix( m: Matrix4 ): Quaternion;
- setFromUnitVectors( vFrom: Vector3, vTo: Vector3 ): Quaternion;
- angleTo( q: Quaternion ): number;
- rotateTowards( q: Quaternion, step: number ): Quaternion;
- identity(): Quaternion;
- /**
- * Inverts this quaternion.
- */
- invert(): Quaternion;
- conjugate(): Quaternion;
- dot( v: Quaternion ): number;
- lengthSq(): number;
- /**
- * Computes length of this quaternion.
- */
- length(): number;
- /**
- * Normalizes this quaternion.
- */
- normalize(): Quaternion;
- /**
- * Multiplies this quaternion by b.
- */
- multiply( q: Quaternion ): Quaternion;
- premultiply( q: Quaternion ): Quaternion;
- /**
- * Sets this quaternion to a x b
- * Adapted from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm.
- */
- multiplyQuaternions( a: Quaternion, b: Quaternion ): Quaternion;
- slerp( qb: Quaternion, t: number ): Quaternion;
- equals( v: Quaternion ): boolean;
- /**
- * Sets this quaternion's x, y, z and w value from the provided array.
- * @param array the source array.
- * @param offset (optional) offset into the array. Default is 0.
- */
- fromArray( array: number[], offset?: number ): this;
- /**
- * Sets this quaternion's x, y, z and w value from the provided array-like.
- * @param array the source array-like.
- * @param offset (optional) offset into the array-like. Default is 0.
- */
- fromArray( array: ArrayLike<number>, offset?: number ): this;
- /**
- * Returns an array [x, y, z, w], or copies x, y, z and w into the provided array.
- * @param array (optional) array to store the quaternion to. If this is not provided, a new array will be created.
- * @param offset (optional) optional offset into the array.
- * @return The created or provided array.
- */
- toArray( array?: number[], offset?: number ): number[];
- /**
- * Copies x, y, z and w into the provided array-like.
- * @param array array-like to store the quaternion to.
- * @param offset (optional) optional offset into the array.
- * @return The provided array-like.
- */
- toArray( array: ArrayLike<number>, offset?: number ): ArrayLike<number>;
- _onChange( callback: Function ): Quaternion;
- _onChangeCallback: Function;
- /**
- * Adapted from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/.
- */
- static slerp(
- qa: Quaternion,
- qb: Quaternion,
- qm: Quaternion,
- t: number
- ): Quaternion;
- static slerpFlat(
- dst: number[],
- dstOffset: number,
- src0: number[],
- srcOffset: number,
- src1: number[],
- stcOffset1: number,
- t: number
- ): Quaternion;
- static multiplyQuaternionsFlat(
- dst: number[],
- dstOffset: number,
- src0: number[],
- srcOffset: number,
- src1: number[],
- stcOffset1: number
- ): number[];
- /**
- * @deprecated Use {@link Vector#applyQuaternion vector.applyQuaternion( quaternion )} instead.
- */
- multiplyVector3( v: any ): any;
- /**
- * @deprecated Use {@link Quaternion#invert .invert()} instead.
- */
- inverse(): Quaternion;
- }
|