Skip to content

Commit d668718

Browse files
committed
Clarified slerp methods in docs
1 parent 9c49051 commit d668718

1 file changed

Lines changed: 42 additions & 20 deletions

File tree

docs/api/math/Quaternion.html

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -120,26 +120,6 @@ <h3>[method:Quaternion clone]()</h3>
120120
Clones this quaternion.
121121
</div>
122122

123-
124-
<h2>Static methods</h2>
125-
126-
<h3>[method:Quaternion slerp]( [page:Quaternion qa], [page:Quaternion qb], [page:Quaternion qm], [page:Float t] )</h3>
127-
<div>
128-
Adapted from [link:http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/].
129-
</div>
130-
131-
132-
<h3>[method:Quaternion slerp]([page:Quaternion qb], [page:float t])</h3>
133-
<div>
134-
qb -- Target quaternion rotation.<br />
135-
t -- Normalized [0..1] interpolation factor.
136-
</div>
137-
<div>
138-
Handles the spherical linear interpolation between this quaternion's configuration
139-
and that of *qb*. *t* represents how close to the current (0) or target (1) rotation the
140-
result should be.
141-
</div>
142-
143123
<h3>[method:Array toArray]( [page:Array array] )</h3>
144124
<div>
145125
array -- Array to store the quaternion.
@@ -176,6 +156,48 @@ <h3>[method:Quaternion conjugate]()</h3>
176156
represents the same rotation in the opposite direction about the rotational axis.
177157
</div>
178158

159+
<h3>[method:Quaternion slerp]([page:Quaternion quaternionB], [page:float t])</h3>
160+
<div>
161+
quaternionB -- The other quaternion rotation<br />
162+
t -- Normalized 0 to 1 interpolation factor
163+
</div>
164+
<div>
165+
Handles the spherical linear interpolation between quaternions. *t* represents the amount of rotation
166+
between this quaternion (where *t* is 0) and quaternionB (where *t* is 1). This quaternion is set to
167+
the result. Also see the static version of the *slerp* below.
168+
</div>
169+
<code>
170+
// rotate a mesh towards a target quaternion
171+
mesh.quaternion.slerp( endQuaternion, 0.01 );
172+
</code>
173+
174+
175+
<h2>Static Methods</h2>
176+
177+
<h3>[method:Quaternion slerp]( [page:Quaternion qStart], [page:Quaternion qEnd], [page:Quaternion qTarget], [page:Float t] )</h3>
178+
<div>
179+
qStart -- The starting quaternion (where *t* is 0)<br />
180+
qEnd -- The ending quaternion (where *t* is 1)<br />
181+
qTarget -- The target quaternion that gets set with the result<br />
182+
t -- Normalized 0 to 1 interpolation factor
183+
</div>
184+
<div>
185+
Unlike the normal method, the static version of slerp sets a target quaternion to the result of the slerp operation.
186+
</div>
187+
<code>
188+
// Code setup
189+
var startQuaternion = new THREE.Quaternion().set( 0, 0, 0, 1 ).normalize();
190+
var endQuaternion = new THREE.Quaternion().set( 1, 1, 1, 1 ).normalize();
191+
var t = 0;
192+
</code>
193+
<code>
194+
// Update a mesh's rotation in the loop
195+
t = ( t + 0.01 ) % 1; // constant angular momentum
196+
THREE.Quaternion.slerp( startQuaternion, endQuaternion, mesh.quaternion, t );
197+
</code>
198+
199+
<!-- Note: Do not add non-static methods to the bottom of this page. Put them above the <h2>Static Methods</h2> -->
200+
179201
<h2>Source</h2>
180202

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

0 commit comments

Comments
 (0)