# [name]

Implementation of a quaternion. This is used for rotating things without incurring in the dreaded gimbal lock issue, amongst other advantages.

## Example

`var q = new THREE.Quaternion(); q.setFromAxisAngle( new THREE.Vector3( 0, 1, 0 ), Math.PI / 2 ); var v = new THREE.Vector3( 1, 0, 0 ); q.multiplyVector3( v );`

## Constructor

### [name]( [page:Float x], [page:Float y], [page:Float z], [page:Float w] )

x - x coordinate
y - y coordinate
z - z coordinate
w - w coordinate

## Properties

### .[page:Float x]

### .[page:Float y]

### .[page:Float z]

### .[page:Float w]

## Methods

### .set( [page:Float x], [page:Float y], [page:Float z], [page:Float w] ) [page:Quaternion]

Sets values of this quaternion.

### .copy( [page:Quaternion q] ) [page:Quaternion]

Copies values of *q* to this quaternion.

### .setFromEuler( [page:Vector3 vector] ) [page:Quaternion]

Sets this quaternion from rotation specified by Euler angles.

### .setFromAxisAngle( [page:Vector3 axis], [page:Float angle] ) [page:Quaternion]

Sets this quaternion from rotation specified by axis and angle.
Adapted from [link:http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm].
*Axis* have to be normalized, *angle* is in radians.

### .setFromRotationMatrix( [page:Matrix4 m] ) [page:Quaternion]

Sets this quaternion from rotation component of *m*. Adapted from [link:http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm].

### .calculateW() [page:Quaternion]

Calculates *w* component of this quaternion.

### .inverse() [page:Quaternion]

Inverts this quaternion.

### .length() [page:Float]

Computes length of this quaternion.

### .normalize() [page:Quaternion]

Normalizes this quaternion.

### .multiply( [page:Quaternion a], [page:Quaternion b] ) [page:Quaternion]

Sets this quaternion to *a x b*
Adapted from [link:http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm].

### .multiplySelf( [page:Quaternion b] ) [page:Quaternion]

Multiplies this quaternion by *b*.

### .multiplyVector3( [page:Vector3 vector], [page:Vector3 dest] ) [page:Quaternion]

Rotates *vector* by this quaternion into *dest*.
If *dest* is not specified, result goes to *vec*.

### .clone() [page:Quaternion]

Clones this quaternion.

## Static methods

### .slerp( [page:Quaternion qa], [page:Quaternion qb], [page:Quaternion qm], [page:Float t] ) [page:Quaternion]

Adapted from [link:http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/].

## Source

[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]