Doodle3D-Slicer/three.js-master/docs/api/math/Quaternion.html

183 lines
5.3 KiB
HTML
Raw Normal View History

2015-06-12 15:58:26 +02:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<script src="../../list.js"></script>
<script src="../../page.js"></script>
<link type="text/css" rel="stylesheet" href="../../page.css" />
</head>
<body>
<h1>[name]</h1>
<div class="desc">Implementation of a <a href="http://en.wikipedia.org/wiki/Quaternion">quaternion</a>. This is used for rotating things without encountering the dreaded <a href="http://en.wikipedia.org/wiki/Gimbal_lock">gimbal lock</a> issue, amongst other advantages.</div>
<h2>Example</h2>
<code>var quaternion = new THREE.Quaternion();
quaternion.setFromAxisAngle( new THREE.Vector3( 0, 1, 0 ), Math.PI / 2 );
var vector = new THREE.Vector3( 1, 0, 0 );
vector.applyQuaternion( quaternion );
</code>
<h2>Constructor</h2>
<h3>[name]( [page:Float x], [page:Float y], [page:Float z], [page:Float w] )</h3>
<div>
x - x coordinate<br />
y - y coordinate<br />
z - z coordinate<br />
w - w coordinate
</div>
<h2>Properties</h2>
<h3>[property:Float x]</h3>
<h3>[property:Float y]</h3>
<h3>[property:Float z]</h3>
<h3>[property:Float w]</h3>
<h2>Methods</h2>
<h3>[method:Quaternion set]( [page:Float x], [page:Float y], [page:Float z], [page:Float w] )</h3>
<div>
Sets values of this quaternion.
</div>
<h3>[method:Quaternion copy]( [page:Quaternion q] )</h3>
<div>
Copies values of *q* to this quaternion.
</div>
<h3>[method:Quaternion setFromEuler]( [page:Euler euler] )</h3>
<div>
Sets this quaternion from rotation specified by Euler angle.
</div>
<h3>[method:Quaternion setFromAxisAngle]( [page:Vector3 axis], [page:Float angle] )</h3>
<div>
Sets this quaternion from rotation specified by axis and angle.<br />
Adapted from [link:http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm].<br />
*Axis* is asumed to be normalized, *angle* is in radians.
</div>
<h3>[method:Quaternion setFromRotationMatrix]( [page:Matrix4 m] )</h3>
<div>
Sets this quaternion from rotation component of *m*.<br />
Adapted from [link:http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm].
</div>
<h3>[method:Quaternion setFromUnitVectors]( [page:Vector3 vFrom], [page:Vector3 vTo] )</h3>
<div>
Sets this quaternion to the rotation required to rotate direction vector *vFrom* to direction vector *vTo*.<br />
Adapted from [link:http://lolengine.net/blog/2013/09/18/beautiful-maths-quaternion-from-vectors].<br />
*vFrom* and *vTo* are assumed to be normalized.
</div>
<h3>[method:Quaternion inverse]()</h3>
<div>
Inverts this quaternion.
</div>
<h3>[method:Float length]()</h3>
<div>
Computes length of this quaternion.
</div>
<h3>[method:Quaternion normalize]()</h3>
<div>
Normalizes this quaternion.
</div>
<h3>[method:Quaternion multiply]( [page:Quaternion b] )</h3>
<div>
Multiplies this quaternion by *b*.
</div>
<h3>[method:Quaternion multiplyQuaternions]( [page:Quaternion a], [page:Quaternion b] )</h3>
<div>
Sets this quaternion to *a x b*<br />
Adapted from [link:http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm].
</div>
<h3>[method:Quaternion multiplyVector3]( [page:Vector3 vector], [page:Vector3 dest] )</h3>
<div>
Rotates *vector* by this quaternion into *dest*.<br />
If *dest* is not specified, result goes to *vec*.
</div>
<h3>[method:Quaternion clone]()</h3>
<div>
Clones this quaternion.
</div>
<h2>Static methods</h2>
<h3>[method:Quaternion slerp]( [page:Quaternion qa], [page:Quaternion qb], [page:Quaternion qm], [page:Float t] )</h3>
<div>
Adapted from [link:http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/].
</div>
<h3>[method:Quaternion slerp]([page:Quaternion qb], [page:float t])</h3>
<div>
qb -- Target quaternion rotation.<br />
t -- Normalized [0..1] interpolation factor.
</div>
<div>
Handles the spherical linear interpolation between this quaternion's configuration
and that of *qb*. *t* represents how close to the current (0) or target (1) rotation the
result should be.
</div>
<h3>[method:Array toArray]( [page:Array array] )</h3>
<div>
array -- Array to store the quaternion.
</div>
<div>
Returns the numerical elements of this quaternion in an array of format (x, y, z, w).
</div>
<h3>[method:Boolean equals]([page:Quaternion v])</h3>
<div>
v -- Quaternion that this quaternion will be compared to.
</div>
<div>
Compares each component of *v* to each component of this quaternion to determine if they
represent the same rotation.
</div>
<h3>[method:Float lengthSq]()</h3>
<div>
Calculates the squared length of the quaternion.
</div>
<h3>[method:Quaternion fromArray]([page:Array array])</h3>
<div>
array -- Array of format (x, y, z, w) used to construct the quaternion.
</div>
<div>
Sets this quaternion's component values from an array.
</div>
<h3>[method:Quaternion conjugate]()</h3>
<div>
Returns the rotational conjugate of this quaternion. The conjugate of a quaternion
represents the same rotation in the opposite direction about the rotational axis.
</div>
<h2>Source</h2>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
</body>
</html>