Vector4.html 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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">4D vector.</div>
  12. <h2>Constructor</h2>
  13. <h3>[name]( [page:Float x], [page:Float y], [page:Float z], [page:Float w] )</h3>
  14. <div>
  15. x -- [page:Float] <br />
  16. y -- [page:Float] <br />
  17. z -- [page:Float] <br />
  18. w -- [page:Float]
  19. </div>
  20. <h2>Properties</h2>
  21. <h3>.[page:Float x]</h3>
  22. <h3>.[page:Float y]</h3>
  23. <h3>.[page:Float z]</h3>
  24. <h3>.[page:Float w]</h3>
  25. <h2>Methods</h2>
  26. <h3>.set( [page:Float x], [page:Float y], [page:Float z], [page:Float w] ) [page:Vector4 this]</h3>
  27. <div>
  28. Sets value of this vector.
  29. </div>
  30. <h3>.copy( [page:Vector4 v] ) [page:Vector4 this]</h3>
  31. <div>
  32. Copies value of *v* to this vector.
  33. </div>
  34. <h3>.add( [page:Vector4 v] ) [page:Vector4 this]</h3>
  35. <div>
  36. Adds *v* to this vector.
  37. </div>
  38. <h3>.addVectors( [page:Vector4 a], [page:Vector4 b] ) [page:Vector4 this]</h3>
  39. <div>
  40. Sets this vector to *a + b*.
  41. </div>
  42. <h3>.sub( [page:Vector4 v] ) [page:Vector4]</h3>
  43. <div>
  44. Subtracts *v* from this vector.
  45. </div>
  46. <h3>.subVectors( [page:Vector4 a], [page:Vector4 b] ) [page:Vector4 this]</h3>
  47. <div>
  48. Sets this vector to *a - b*.
  49. </div>
  50. <h3>.multiplyScalar( [page:Float s] ) [page:Vector4 this]</h3>
  51. <div>
  52. Multiplies this vector by scalar *s*.
  53. </div>
  54. <h3>.divideScalar( [page:Float s] ) [page:Vector4 this]</h3>
  55. <div>
  56. Divides this vector by scalar *s*.<br />
  57. Set vector to *( 0, 0, 0 )* if *s == 0*.
  58. </div>
  59. <h3>.negate() [page:Vector4 this]</h3>
  60. <div>
  61. Inverts this vector.
  62. </div>
  63. <h3>.dot( [page:Vector4 v] ) [page:Float]</h3>
  64. <div>
  65. Computes dot product of this vector and *v*.
  66. </div>
  67. <h3>.lengthSq() [page:Float]</h3>
  68. <div>
  69. Computes squared length of this vector.
  70. </div>
  71. <h3>.length() [page:Float]</h3>
  72. <div>
  73. Computes length of this vector.
  74. </div>
  75. <h3>.normalize() [page:Vector4 this]</h3>
  76. <div>
  77. Normalizes this vector.
  78. </div>
  79. <h3>.setLength( [page:Float l] ) [page:Vector4 this]</h3>
  80. <div>
  81. Normalizes this vector and multiplies it by *l*.
  82. </div>
  83. <h3>.lerp( [page:Vector4 v], [page:Float alpha] ) [page:Vector4 this]</h3>
  84. <div>
  85. Linearly interpolate between this vector and *v* with *alpha* factor.
  86. </div>
  87. <h3>.clone() [page:Vector4]</h3>
  88. <div>
  89. Clones this vector.
  90. </div>
  91. <h3>.clamp([page:Vector4 min], [page:Vector4 max]) [page:Vector4 this]</h3>
  92. <div>
  93. min -- [page:Vector4] <br />
  94. max -- [page:Vector4]
  95. </div>
  96. <div>
  97. If this vector's x, y, z, or w value is greater than the max vector's x, y, z, or w value, it is replaced by the corresponding value.<br/><br/>
  98. If this vector's x, y, z, or w value is less than the min vector's x, y, z, or w value, it is replace by the corresponding value.
  99. </div>
  100. <h3>.applyMatrix4([page:Matrix4 m]) [page:Vector4 this]</h3>
  101. <div>
  102. m -- [page:Matrix4]
  103. </div>
  104. <div>
  105. Transforms the vector by the matrix.
  106. </div>
  107. <h3>.min([page:Vector4 v]) [page:Vector4 this]</h3>
  108. <div>
  109. v -- [page:Vector4]
  110. </div>
  111. <div>
  112. If this vector's x, y, z, or w value is less than vector v's x, y, z, or w value, that value is replaced by the corresponding vector v value.
  113. </div>
  114. <h3>.max([page:Vector4 v]) [page:Vector4 this]</h3>
  115. <div>
  116. v -- [page:Vector4]
  117. </div>
  118. <div>
  119. If this vector's x, y, z, or w value is greater than vector v's x, y, z, or w value, that value is replaced by the corresponding vector v value.
  120. </div>
  121. <h3>.addScalar([page:Float s]) [page:Vector4 this]</h3>
  122. <div>
  123. s -- [page:Float]
  124. </div>
  125. <div>
  126. Adds a scalar value to all of the vector's components.
  127. </div>
  128. <h3>.equals([page:Vector4 v]) [page:Boolean]</h3>
  129. <div>
  130. v -- [page:Vector4]
  131. </div>
  132. <div>
  133. Checks to see if this vector matches vector v.
  134. </div>
  135. <h3>.setAxisAngleFromRotationMatrix([page:Matrix4 m]) [page:Vector4 this]</h3>
  136. <div>
  137. m -- [page:Matrix4]
  138. </div>
  139. <div>
  140. Sets this Vector4 to the computed <a href='http://en.wikipedia.org/wiki/Axis%E2%80%93angle_representation' target='_blank'>axis-angle representation</a> of the rotation defined by Matrix4 m. Assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled).<br/><br/>
  141. The axis is stored in components (x, y, z) of the vector, and the rotation in radians is stored in component w
  142. </div>
  143. <h3>.setAxisAngleFromQuaternion([page:Quaternion q]) [page:Vector4 this]</h3>
  144. <div>
  145. q -- [page:Quaternion]
  146. </div>
  147. <div>
  148. Sets this Vector4 to the computed <a href='http://en.wikipedia.org/wiki/Axis%E2%80%93angle_representation' target='_blank'>axis-angle representation</a> of the rotation defined by Quaternion q.<br/><br/>
  149. The axis is stored in components (x, y, z) of the vector, and the rotation in radians is stored in component w
  150. </div>
  151. <h3>.getComponent([page:Integer index]) [page:Float]</h3>
  152. <div>
  153. index -- [page:Integer] 0, 1, 2, or 3
  154. </div>
  155. <div>
  156. Returns the value of the vector component x, y, or z by an index.<br/><br/>
  157. Index 0: x<br/>
  158. Index 1: y<br/>
  159. Index 2: z<br/>
  160. Index 3: w<br/>
  161. </div>
  162. <h3>.setComponent([page:Integer index], [page:Float value])</h3>
  163. <div>
  164. index -- [page:Integer] 0 - 3 <br />
  165. value -- [page:Float]
  166. </div>
  167. <div>
  168. Sets the value of the vector component x, y, or z by an index.<br/><br/>
  169. Index 0: x<br/>
  170. Index 1: y<br/>
  171. Index 2: z<br/>
  172. Index 3: w<br/>
  173. </div>
  174. <h3>.fromArray([page:Array array]) [page:Vector4 this]</h3>
  175. <div>
  176. array -- [page:Array] An array formatted [x, y, z, w]
  177. </div>
  178. <div>
  179. Sets the vector's components based on an array formatted like [x, y, z, w]
  180. </div>
  181. <h3>.toArray() [page:Array]</h3>
  182. <div>
  183. Returns an array in the format [x, y, z, w]
  184. </div>
  185. <h3>.lengthManhattan() [page:Float]</h3>
  186. <div>
  187. Computes Manhattan length of this vector.<br />
  188. [link:http://en.wikipedia.org/wiki/Taxicab_geometry]
  189. </div>
  190. <h3>.setX([page:Float x]) [page:Vector4 this]</h3>
  191. <div>
  192. x -- [page:Float]
  193. </div>
  194. <div>
  195. Sets the x component of the vector.
  196. </div>
  197. <h3>.setY([page:Float y]) [page:Vector4 this]</h3>
  198. <div>
  199. y -- [page:Float]
  200. </div>
  201. <div>
  202. Sets the y component of the vector.
  203. </div>
  204. <h3>.setZ([page:Float z]) [page:Vector4 this]</h3>
  205. <div>
  206. z -- [page:Float]
  207. </div>
  208. <div>
  209. Sets the z component of the vector.
  210. </div>
  211. <h3>.setW([page:Float w]) [page:Vector4 this]</h3>
  212. <div>
  213. w -- [page:Float]
  214. </div>
  215. <div>
  216. Sets the w component of the vector.
  217. </div>
  218. <h2>Source</h2>
  219. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  220. </body>
  221. </html>