Quaternion.html 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <script src="../../list.js"></script>
  6. <script src="../../page.js"></script>
  7. <link type="text/css" rel="stylesheet" href="../../page.css" />
  8. </head>
  9. <body>
  10. <h1>[name]</h1>
  11. <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>
  12. <h2>Example</h2>
  13. <code>var quaternion = new THREE.Quaternion();
  14. quaternion.setFromAxisAngle( new THREE.Vector3( 0, 1, 0 ), Math.PI / 2 );
  15. var vector = new THREE.Vector3( 1, 0, 0 );
  16. vector.applyQuaternion( quaternion );
  17. </code>
  18. <h2>Constructor</h2>
  19. <h3>[name]( [page:Float x], [page:Float y], [page:Float z], [page:Float w] )</h3>
  20. <div>
  21. x - x coordinate<br />
  22. y - y coordinate<br />
  23. z - z coordinate<br />
  24. w - w coordinate
  25. </div>
  26. <h2>Properties</h2>
  27. <h3>.[page:Float x]</h3>
  28. <h3>.[page:Float y]</h3>
  29. <h3>.[page:Float z]</h3>
  30. <h3>.[page:Float w]</h3>
  31. <h2>Methods</h2>
  32. <h3>.set( [page:Float x], [page:Float y], [page:Float z], [page:Float w] ) [page:Quaternion]</h3>
  33. <div>
  34. Sets values of this quaternion.
  35. </div>
  36. <h3>.copy( [page:Quaternion q] ) [page:Quaternion]</h3>
  37. <div>
  38. Copies values of *q* to this quaternion.
  39. </div>
  40. <h3>.setFromEuler( [page:Vector3 vector] ) [page:Quaternion]</h3>
  41. <div>
  42. Sets this quaternion from rotation specified by Euler angles.
  43. </div>
  44. <h3>.setFromAxisAngle( [page:Vector3 axis], [page:Float angle] ) [page:Quaternion]</h3>
  45. <div>
  46. Sets this quaternion from rotation specified by axis and angle.<br />
  47. Adapted from [link:http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm].<br />
  48. *Axis* have to be normalized, *angle* is in radians.
  49. </div>
  50. <h3>.setFromRotationMatrix( [page:Matrix4 m] ) [page:Quaternion]</h3>
  51. <div>
  52. Sets this quaternion from rotation component of *m*.
  53. Adapted from [link:http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm].
  54. </div>
  55. <h3>.inverse() [page:Quaternion]</h3>
  56. <div>
  57. Inverts this quaternion.
  58. </div>
  59. <h3>.length() [page:Float]</h3>
  60. <div>
  61. Computes length of this quaternion.
  62. </div>
  63. <h3>.normalize() [page:Quaternion]</h3>
  64. <div>
  65. Normalizes this quaternion.
  66. </div>
  67. <h3>.multiply( [page:Quaternion b] ) [page:Quaternion]</h3>
  68. <div>
  69. Multiplies this quaternion by *b*.
  70. </div>
  71. <h3>.multiplyQuaternions( [page:Quaternion a], [page:Quaternion b] ) [page:Quaternion]</h3>
  72. <div>
  73. Sets this quaternion to *a x b*<br />
  74. Adapted from [link:http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm].
  75. </div>
  76. <h3>.multiplyVector3( [page:Vector3 vector], [page:Vector3 dest] ) [page:Quaternion]</h3>
  77. <div>
  78. Rotates *vector* by this quaternion into *dest*.<br />
  79. If *dest* is not specified, result goes to *vec*.
  80. </div>
  81. <h3>.clone() [page:Quaternion]</h3>
  82. <div>
  83. Clones this quaternion.
  84. </div>
  85. <h2>Static methods</h2>
  86. <h3>.slerp( [page:Quaternion qa], [page:Quaternion qb], [page:Quaternion qm], [page:Float t] ) [page:Quaternion]</h3>
  87. <div>
  88. Adapted from [link:http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/].
  89. </div>
  90. <h3>.slerp([page:todo qb], [page:todo t]) [page:todo]</h3>
  91. <div>
  92. qb -- todo <br />
  93. t -- todo
  94. </div>
  95. <div>
  96. todo
  97. </div>
  98. <h3>.toArray() [page:todo]</h3>
  99. <div>
  100. todo
  101. </div>
  102. <h3>.equals([page:todo v]) [page:todo]</h3>
  103. <div>
  104. v -- todo
  105. </div>
  106. <div>
  107. todo
  108. </div>
  109. <h3>.lengthSq() [page:todo]</h3>
  110. <div>
  111. todo
  112. </div>
  113. <h3>.fromArray([page:todo array]) [page:todo]</h3>
  114. <div>
  115. array -- todo
  116. </div>
  117. <div>
  118. todo
  119. </div>
  120. <h3>.conjugate() [page:todo]</h3>
  121. <div>
  122. todo
  123. </div>
  124. <h2>Source</h2>
  125. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  126. </body>
  127. </html>