Quaternion.html 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <h1>[name]</h1>
  2. <div class="desc">Implementation of a quaternion</div>
  3. <h2>Example</h2>
  4. <code>var q = new THREE.Quaternion();
  5. q.setFromAxisAngle( new THREE.Vector3( 0, 1, 0 ), Math.PI / 2 );
  6. var v = new THREE.Vector3( 1, 0, 0 );
  7. q.multiplyVector3( v );
  8. </code>
  9. <h2>Constructor</h2>
  10. <h3>[name]( [page:Float x], [page:Float y], [page:Float z], [page:Float w] )</h3>
  11. <div>
  12. x - x coordinate<br />
  13. y - y coordinate<br />
  14. z - z coordinate<br />
  15. w - w coordinate
  16. </div>
  17. <h2>Properties</h2>
  18. <h3>.[page:Float x]</h3>
  19. <h3>.[page:Float y]</h3>
  20. <h3>.[page:Float z]</h3>
  21. <h3>.[page:Float w]</h3>
  22. <h2>Methods</h2>
  23. <h3>.set( [page:Float x], [page:Float y], [page:Float z], [page:Float w] ) [page:Quaternion]</h3>
  24. <div>
  25. Sets values of this quaternion.
  26. </div>
  27. <h3>.copy( [page:Quaternion q] ) [page:Quaternion]</h3>
  28. <div>
  29. Copies values of *q* to this quaternion.
  30. </div>
  31. <h3>.setFromEuler( [page:Vector3 vector] ) [page:Quaternion]</h3>
  32. <div>
  33. Sets this quaternion from rotation specified by Euler angles.
  34. </div>
  35. <h3>.setFromAxisAngle( [page:Vector3 axis], [page:Float angle] ) [page:Quaternion]</h3>
  36. <div>
  37. Sets this quaternion from rotation specified by axis and angle.<br />
  38. Adapted from [link:http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm].<br />
  39. *Axis* have to be normalized, *angle* is in radians.
  40. </div>
  41. <h3>.setFromRotationMatrix( [page:Matrix4 m] ) [page:Quaternion]</h3>
  42. <div>
  43. Sets this quaternion from rotation component of *m*.
  44. Adapted from [link:http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm].
  45. </div>
  46. <h3>.calculateW() [page:Quaternion]</h3>
  47. <div>
  48. Calculates *w* component of this quaternion.
  49. </div>
  50. <h3>.inverse() [page:Quaternion]</h3>
  51. <div>
  52. Inverts this quaternion.
  53. </div>
  54. <h3>.length() [page:Float]</h3>
  55. <div>
  56. Computes length of this quaternion.
  57. </div>
  58. <h3>.normalize() [page:Quaternion]</h3>
  59. <div>
  60. Normalizes this quaternion.
  61. </div>
  62. <h3>.multiply( [page:Quaternion a], [page:Quaternion b] ) [page:Quaternion]</h3>
  63. <div>
  64. Sets this quaternion to *a x b*<br />
  65. Adapted from [link:http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm].
  66. </div>
  67. <h3>.multiplySelf( [page:Quaternion b] ) [page:Quaternion]</h3>
  68. <div>
  69. Multiplies this quaternion by *b*.
  70. </div>
  71. <h3>.multiplyVector3( [page:Vector3 vector], [page:Vector3 dest] ) [page:Quaternion]</h3>
  72. <div>
  73. Rotates *vector* by this quaternion into *dest*.<br />
  74. If *dest* is not specified, result goes to *vec*.
  75. </div>
  76. <h3>.clone() [page:Quaternion]</h3>
  77. <div>
  78. Clones this quaternion.
  79. </div>
  80. <h2>Static methods</h2>
  81. <h3>.slerp( [page:Quaternion qa], [page:Quaternion qb], [page:Quaternion qm], [page:Float t] ) [page:Quaternion]</h3>
  82. <div>
  83. Adapted from [link:http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/].
  84. </div>
  85. <h2>Source</h2>
  86. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]