| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Quaternion - Three.js Docs</title>
- <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
- <script src="../scripts/highlight.min.js"></script>
- <link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
- <link type="text/css" rel="stylesheet" href="../styles/page.css">
- </head>
- <body>
- <h1 translate="no">Quaternion</h1>
- <section>
- <header>
- <div class="class-description"><p>Class for representing a Quaternion. Quaternions are used in three.js to represent rotations.</p>
- <p>Iterating through a vector instance will yield its components <code>(x, y, z, w)</code> in
- the corresponding order.</p>
- <p>Note that three.js expects Quaternions to be normalized.</p></div>
- <h2>Code Example</h2>
- <div translate="no"><pre><code class="language-js">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 );
- </code></pre></div>
- </header>
- <article>
- <div class="container-overview">
- <h2>Constructor</h2>
- <h3 class="name name-method" id="Quaternion" translate="no">new <a href="#Quaternion">Quaternion</a><span class="signature">( x : <span class="param-type">number</span>, y : <span class="param-type">number</span>, z : <span class="param-type">number</span>, w : <span class="param-type">number</span> )</span> </h3>
- <div class="method">
- <div class="description">
- <p>Constructs a new quaternion.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>x</strong>
- </td>
- <td class="description last">
- <p>The x value of this quaternion.</p>
- <p>Default is <code>0</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>y</strong>
- </td>
- <td class="description last">
- <p>The y value of this quaternion.</p>
- <p>Default is <code>0</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>z</strong>
- </td>
- <td class="description last">
- <p>The z value of this quaternion.</p>
- <p>Default is <code>0</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>w</strong>
- </td>
- <td class="description last">
- <p>The w value of this quaternion.</p>
- <p>Default is <code>1</code>.</p>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- <h2 class="subsection-title">Properties</h2>
- <div class="member">
- <h3 class="name" id="isQuaternion" translate="no">.<a href="#isQuaternion">isQuaternion</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
- <div class="description">
- <p>This flag can be used for type testing.</p>
- <p>Default is <code>true</code>.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="w" translate="no">.<a href="#w">w</a><span class="type-signature"> : number</span> </h3>
- <div class="description">
- <p>The w value of this quaternion.</p>
- <p>Default is <code>1</code>.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="x" translate="no">.<a href="#x">x</a><span class="type-signature"> : number</span> </h3>
- <div class="description">
- <p>The x value of this quaternion.</p>
- <p>Default is <code>0</code>.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="y" translate="no">.<a href="#y">y</a><span class="type-signature"> : number</span> </h3>
- <div class="description">
- <p>The y value of this quaternion.</p>
- <p>Default is <code>0</code>.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="z" translate="no">.<a href="#z">z</a><span class="type-signature"> : number</span> </h3>
- <div class="description">
- <p>The z value of this quaternion.</p>
- <p>Default is <code>0</code>.</p>
- </div>
- </div>
- <h2 class="subsection-title">Methods</h2>
- <h3 class="name name-method" id="angleTo" translate="no">.<a href="#angleTo">angleTo</a><span class="signature">( q : <span class="param-type"><a href="Quaternion.html">Quaternion</a></span> )</span><span class="type-signature"> : number</span> </h3>
- <div class="method">
- <div class="description">
- <p>Returns the angle between this quaternion and the given one in radians.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>q</strong>
- </td>
- <td class="description last">
- <p>The quaternion to compute the angle with.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> The angle in radians.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="clone" translate="no">.<a href="#clone">clone</a><span class="signature">()</span><span class="type-signature"> : <a href="Quaternion.html">Quaternion</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Returns a new quaternion with copied values from this instance.</p>
- </div>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A clone of this instance.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="conjugate" translate="no">.<a href="#conjugate">conjugate</a><span class="signature">()</span><span class="type-signature"> : <a href="Quaternion.html">Quaternion</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Returns the rotational conjugate of this quaternion. The conjugate of a
- quaternion represents the same rotation in the opposite direction about
- the rotational axis.</p>
- </div>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this quaternion.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="copy" translate="no">.<a href="#copy">copy</a><span class="signature">( quaternion : <span class="param-type"><a href="Quaternion.html">Quaternion</a></span> )</span><span class="type-signature"> : <a href="Quaternion.html">Quaternion</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Copies the values of the given quaternion to this instance.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>quaternion</strong>
- </td>
- <td class="description last">
- <p>The quaternion to copy.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this quaternion.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="dot" translate="no">.<a href="#dot">dot</a><span class="signature">( v : <span class="param-type"><a href="Quaternion.html">Quaternion</a></span> )</span><span class="type-signature"> : number</span> </h3>
- <div class="method">
- <div class="description">
- <p>Calculates the dot product of this quaternion and the given one.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>v</strong>
- </td>
- <td class="description last">
- <p>The quaternion to compute the dot product with.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> The result of the dot product.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="equals" translate="no">.<a href="#equals">equals</a><span class="signature">( quaternion : <span class="param-type"><a href="Quaternion.html">Quaternion</a></span> )</span><span class="type-signature"> : boolean</span> </h3>
- <div class="method">
- <div class="description">
- <p>Returns <code>true</code> if this quaternion is equal with the given one.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>quaternion</strong>
- </td>
- <td class="description last">
- <p>The quaternion to test for equality.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> Whether this quaternion is equal with the given one.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="fromArray" translate="no">.<a href="#fromArray">fromArray</a><span class="signature">( array : <span class="param-type">Array.<number></span>, offset : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Quaternion.html">Quaternion</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Sets this quaternion's components from the given array.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>array</strong>
- </td>
- <td class="description last">
- <p>An array holding the quaternion component values.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>offset</strong>
- </td>
- <td class="description last">
- <p>The offset into the array.</p>
- <p>Default is <code>0</code>.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this quaternion.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="fromBufferAttribute" translate="no">.<a href="#fromBufferAttribute">fromBufferAttribute</a><span class="signature">( attribute : <span class="param-type"><a href="BufferAttribute.html">BufferAttribute</a></span>, index : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Quaternion.html">Quaternion</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Sets the components of this quaternion from the given buffer attribute.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>attribute</strong>
- </td>
- <td class="description last">
- <p>The buffer attribute holding quaternion data.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>index</strong>
- </td>
- <td class="description last">
- <p>The index into the attribute.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this quaternion.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="identity" translate="no">.<a href="#identity">identity</a><span class="signature">()</span><span class="type-signature"> : <a href="Quaternion.html">Quaternion</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Sets this quaternion to the identity quaternion; that is, to the
- quaternion that represents "no rotation".</p>
- </div>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this quaternion.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="invert" translate="no">.<a href="#invert">invert</a><span class="signature">()</span><span class="type-signature"> : <a href="Quaternion.html">Quaternion</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Inverts this quaternion via <a href="Quaternion.html#conjugate">Quaternion#conjugate</a>. The
- quaternion is assumed to have unit length.</p>
- </div>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this quaternion.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="length" translate="no">.<a href="#length">length</a><span class="signature">()</span><span class="type-signature"> : number</span> </h3>
- <div class="method">
- <div class="description">
- <p>Computes the Euclidean length (straight-line length) of this quaternion,
- considered as a 4 dimensional vector.</p>
- </div>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> The Euclidean length.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="lengthSq" translate="no">.<a href="#lengthSq">lengthSq</a><span class="signature">()</span><span class="type-signature"> : number</span> </h3>
- <div class="method">
- <div class="description">
- <p>Computes the squared Euclidean length (straight-line length) of this quaternion,
- considered as a 4 dimensional vector. This can be useful if you are comparing the
- lengths of two quaternions, as this is a slightly more efficient calculation than
- <a href="Quaternion.html#length">Quaternion#length</a>.</p>
- </div>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> The squared Euclidean length.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="multiply" translate="no">.<a href="#multiply">multiply</a><span class="signature">( q : <span class="param-type"><a href="Quaternion.html">Quaternion</a></span> )</span><span class="type-signature"> : <a href="Quaternion.html">Quaternion</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Multiplies this quaternion by the given one.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>q</strong>
- </td>
- <td class="description last">
- <p>The quaternion.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this quaternion.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="multiplyQuaternions" translate="no">.<a href="#multiplyQuaternions">multiplyQuaternions</a><span class="signature">( a : <span class="param-type"><a href="Quaternion.html">Quaternion</a></span>, b : <span class="param-type"><a href="Quaternion.html">Quaternion</a></span> )</span><span class="type-signature"> : <a href="Quaternion.html">Quaternion</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Multiplies the given quaternions and stores the result in this instance.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>a</strong>
- </td>
- <td class="description last">
- <p>The first quaternion.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>b</strong>
- </td>
- <td class="description last">
- <p>The second quaternion.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this quaternion.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="normalize" translate="no">.<a href="#normalize">normalize</a><span class="signature">()</span><span class="type-signature"> : <a href="Quaternion.html">Quaternion</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Normalizes this quaternion - that is, calculated the quaternion that performs
- the same rotation as this one, but has a length equal to <code>1</code>.</p>
- </div>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this quaternion.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="premultiply" translate="no">.<a href="#premultiply">premultiply</a><span class="signature">( q : <span class="param-type"><a href="Quaternion.html">Quaternion</a></span> )</span><span class="type-signature"> : <a href="Quaternion.html">Quaternion</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Pre-multiplies this quaternion by the given one.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>q</strong>
- </td>
- <td class="description last">
- <p>The quaternion.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this quaternion.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="random" translate="no">.<a href="#random">random</a><span class="signature">()</span><span class="type-signature"> : <a href="Quaternion.html">Quaternion</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Sets this quaternion to a uniformly random, normalized quaternion.</p>
- </div>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this quaternion.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="rotateTowards" translate="no">.<a href="#rotateTowards">rotateTowards</a><span class="signature">( q : <span class="param-type"><a href="Quaternion.html">Quaternion</a></span>, step : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Quaternion.html">Quaternion</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Rotates this quaternion by a given angular step to the given quaternion.
- The method ensures that the final quaternion will not overshoot <code>q</code>.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>q</strong>
- </td>
- <td class="description last">
- <p>The target quaternion.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>step</strong>
- </td>
- <td class="description last">
- <p>The angular step in radians.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this quaternion.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="set" translate="no">.<a href="#set">set</a><span class="signature">( x : <span class="param-type">number</span>, y : <span class="param-type">number</span>, z : <span class="param-type">number</span>, w : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Quaternion.html">Quaternion</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Sets the quaternion components.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>x</strong>
- </td>
- <td class="description last">
- <p>The x value of this quaternion.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>y</strong>
- </td>
- <td class="description last">
- <p>The y value of this quaternion.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>z</strong>
- </td>
- <td class="description last">
- <p>The z value of this quaternion.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>w</strong>
- </td>
- <td class="description last">
- <p>The w value of this quaternion.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this quaternion.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="setFromAxisAngle" translate="no">.<a href="#setFromAxisAngle">setFromAxisAngle</a><span class="signature">( axis : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, angle : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Quaternion.html">Quaternion</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Sets this quaternion from the given axis and angle.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>axis</strong>
- </td>
- <td class="description last">
- <p>The normalized axis.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>angle</strong>
- </td>
- <td class="description last">
- <p>The angle in radians.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this quaternion.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="setFromEuler" translate="no">.<a href="#setFromEuler">setFromEuler</a><span class="signature">( euler : <span class="param-type"><a href="Euler.html">Euler</a></span>, update : <span class="param-type">boolean</span> )</span><span class="type-signature"> : <a href="Quaternion.html">Quaternion</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Sets this quaternion from the rotation specified by the given
- Euler angles.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>euler</strong>
- </td>
- <td class="description last">
- <p>The Euler angles.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>update</strong>
- </td>
- <td class="description last">
- <p>Whether the internal <code>onChange</code> callback should be executed or not.</p>
- <p>Default is <code>true</code>.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this quaternion.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="setFromRotationMatrix" translate="no">.<a href="#setFromRotationMatrix">setFromRotationMatrix</a><span class="signature">( m : <span class="param-type"><a href="Matrix4.html">Matrix4</a></span> )</span><span class="type-signature"> : <a href="Quaternion.html">Quaternion</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Sets this quaternion from the given rotation matrix.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>m</strong>
- </td>
- <td class="description last">
- <p>A 4x4 matrix of which the upper 3x3 of matrix is a pure rotation matrix (i.e. unscaled).</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this quaternion.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="setFromUnitVectors" translate="no">.<a href="#setFromUnitVectors">setFromUnitVectors</a><span class="signature">( vFrom : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, vTo : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Quaternion.html">Quaternion</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Sets this quaternion to the rotation required to rotate the direction vector
- <code>vFrom</code> to the direction vector <code>vTo</code>.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>vFrom</strong>
- </td>
- <td class="description last">
- <p>The first (normalized) direction vector.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>vTo</strong>
- </td>
- <td class="description last">
- <p>The second (normalized) direction vector.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this quaternion.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="slerp" translate="no">.<a href="#slerp">slerp</a><span class="signature">( qb : <span class="param-type"><a href="Quaternion.html">Quaternion</a></span>, t : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Quaternion.html">Quaternion</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Performs a spherical linear interpolation between quaternions.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>qb</strong>
- </td>
- <td class="description last">
- <p>The target quaternion.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>t</strong>
- </td>
- <td class="description last">
- <p>The interpolation factor in the closed interval <code>[0, 1]</code>.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this quaternion.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="slerpQuaternions" translate="no">.<a href="#slerpQuaternions">slerpQuaternions</a><span class="signature">( qa : <span class="param-type"><a href="Quaternion.html">Quaternion</a></span>, qb : <span class="param-type"><a href="Quaternion.html">Quaternion</a></span>, t : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Quaternion.html">Quaternion</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Performs a spherical linear interpolation between the given quaternions
- and stores the result in this quaternion.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>qa</strong>
- </td>
- <td class="description last">
- <p>The source quaternion.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>qb</strong>
- </td>
- <td class="description last">
- <p>The target quaternion.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>t</strong>
- </td>
- <td class="description last">
- <p>The interpolation factor in the closed interval <code>[0, 1]</code>.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this quaternion.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="toArray" translate="no">.<a href="#toArray">toArray</a><span class="signature">( array : <span class="param-type">Array.<number></span>, offset : <span class="param-type">number</span> )</span><span class="type-signature"> : Array.<number></span> </h3>
- <div class="method">
- <div class="description">
- <p>Writes the components of this quaternion to the given array. If no array is provided,
- the method returns a new instance.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>array</strong>
- </td>
- <td class="description last">
- <p>The target array holding the quaternion components.</p>
- <p>Default is <code>[]</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>offset</strong>
- </td>
- <td class="description last">
- <p>Index of the first element in the array.</p>
- <p>Default is <code>0</code>.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> The quaternion components.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="toJSON" translate="no">.<a href="#toJSON">toJSON</a><span class="signature">()</span><span class="type-signature"> : Array.<number></span> </h3>
- <div class="method">
- <div class="description">
- <p>This methods defines the serialization result of this class. Returns the
- numerical elements of this quaternion in an array of format <code>[x, y, z, w]</code>.</p>
- </div>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> The serialized quaternion.</dt>
- </dl>
- </div>
- <h2 class="subsection-title">Static Methods</h2>
- <h3 class="name name-method" id=".multiplyQuaternionsFlat" translate="no">.<a href="#.multiplyQuaternionsFlat">multiplyQuaternionsFlat</a><span class="signature">( dst : <span class="param-type">Array.<number></span>, dstOffset : <span class="param-type">number</span>, src0 : <span class="param-type">Array.<number></span>, srcOffset0 : <span class="param-type">number</span>, src1 : <span class="param-type">Array.<number></span>, srcOffset1 : <span class="param-type">number</span> )</span><span class="type-signature"> : Array.<number></span> </h3>
- <div class="method">
- <div class="description">
- <p>Multiplies two quaternions. This implementation assumes the quaternion data are managed
- in flat arrays.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>dst</strong>
- </td>
- <td class="description last">
- <p>The destination array.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>dstOffset</strong>
- </td>
- <td class="description last">
- <p>An offset into the destination array.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>src0</strong>
- </td>
- <td class="description last">
- <p>The source array of the first quaternion.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>srcOffset0</strong>
- </td>
- <td class="description last">
- <p>An offset into the first source array.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>src1</strong>
- </td>
- <td class="description last">
- <p>The source array of the second quaternion.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>srcOffset1</strong>
- </td>
- <td class="description last">
- <p>An offset into the second source array.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-see">See:</dt>
- <dd class="tag-see">
- <ul>
- <li><a href="Quaternion.html#multiplyQuaternions">Quaternion#multiplyQuaternions</a>.</li>
- </ul>
- </dd>
- </dl>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> The destination array.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id=".slerpFlat" translate="no">.<a href="#.slerpFlat">slerpFlat</a><span class="signature">( dst : <span class="param-type">Array.<number></span>, dstOffset : <span class="param-type">number</span>, src0 : <span class="param-type">Array.<number></span>, srcOffset0 : <span class="param-type">number</span>, src1 : <span class="param-type">Array.<number></span>, srcOffset1 : <span class="param-type">number</span>, t : <span class="param-type">number</span> )</span> </h3>
- <div class="method">
- <div class="description">
- <p>Interpolates between two quaternions via SLERP. This implementation assumes the
- quaternion data are managed in flat arrays.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>dst</strong>
- </td>
- <td class="description last">
- <p>The destination array.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>dstOffset</strong>
- </td>
- <td class="description last">
- <p>An offset into the destination array.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>src0</strong>
- </td>
- <td class="description last">
- <p>The source array of the first quaternion.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>srcOffset0</strong>
- </td>
- <td class="description last">
- <p>An offset into the first source array.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>src1</strong>
- </td>
- <td class="description last">
- <p>The source array of the second quaternion.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>srcOffset1</strong>
- </td>
- <td class="description last">
- <p>An offset into the second source array.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>t</strong>
- </td>
- <td class="description last">
- <p>The interpolation factor in the range <code>[0,1]</code>.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-see">See:</dt>
- <dd class="tag-see">
- <ul>
- <li><a href="Quaternion.html#slerp">Quaternion#slerp</a></li>
- </ul>
- </dd>
- </dl>
- </div>
- <h2 class="subsection-title">Source</h2>
- <p>
- <a href="https://github.com/mrdoob/three.js/blob/master/src/math/Quaternion.js" translate="no" target="_blank" rel="noopener">src/math/Quaternion.js</a>
- </p>
- </article>
- </section>
- <script src="../scripts/linenumber.js"></script>
- <script src="../scripts/page.js"></script>
- </body>
- </html>
|