Vector4.html 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../" />
  6. <script src="list.js"></script>
  7. <script src="page.js"></script>
  8. <link type="text/css" rel="stylesheet" href="page.css" />
  9. </head>
  10. <body>
  11. <h1>[name]</h1>
  12. <div class="desc">4D vector.</div>
  13. <h2>Constructor</h2>
  14. <h3>[name]( [page:Float x], [page:Float y], [page:Float z], [page:Float w] )</h3>
  15. <div>
  16. x -- [page:Float] <br />
  17. y -- [page:Float] <br />
  18. z -- [page:Float] <br />
  19. w -- [page:Float]
  20. </div>
  21. <h2>Properties</h2>
  22. <h3>[property:Float x]</h3>
  23. <h3>[property:Float y]</h3>
  24. <h3>[property:Float z]</h3>
  25. <h3>[property:Float w]</h3>
  26. <h2>Methods</h2>
  27. <h3>[method:Vector4 set]( [page:Float x], [page:Float y], [page:Float z], [page:Float w] ) [page:Vector4 this]</h3>
  28. <div>
  29. Sets value of this vector.
  30. </div>
  31. <h3>[method:Vector4 setX]( [page:Float x] ) [page:Vector4 this]</h3>
  32. <div>
  33. x -- [page:Float]
  34. </div>
  35. <div>
  36. Sets the x component of the vector.
  37. </div>
  38. <h3>[method:Vector4 setY]( [page:Float y] ) [page:Vector4 this]</h3>
  39. <div>
  40. y -- [page:Float]
  41. </div>
  42. <div>
  43. Sets the y component of the vector.
  44. </div>
  45. <h3>[method:Vector4 setZ]( [page:Float z] ) [page:Vector4 this]</h3>
  46. <div>
  47. z -- [page:Float]
  48. </div>
  49. <div>
  50. Sets the z component of the vector.
  51. </div>
  52. <h3>[method:Vector4 setW]( [page:Float w] ) [page:Vector4 this]</h3>
  53. <div>
  54. w -- [page:Float]
  55. </div>
  56. <div>
  57. Sets the w component of the vector.
  58. </div>
  59. <h3>[method:Vector4 copy]( [page:Vector4 v] ) [page:Vector4 this]</h3>
  60. <div>
  61. Copies value of *v* to this vector.
  62. </div>
  63. <h3>[method:Vector4 fromArray]( [page:Array array] ) [page:Vector4 this]</h3>
  64. <div>
  65. array -- The source array in the form [x, y, z, w]. <br />
  66. offset -- An optional offset into the array.
  67. </div>
  68. <div>
  69. Sets the vector's components based on an array formatted like [x, y, z, w]
  70. </div>
  71. <h3>[method:Vector4 add]( [page:Vector4 v] ) [page:Vector4 this]</h3>
  72. <div>
  73. Adds *v* to this vector.
  74. </div>
  75. <h3>[method:Vector4 addVectors]( [page:Vector4 a], [page:Vector4 b] ) [page:Vector4 this]</h3>
  76. <div>
  77. Sets this vector to *a + b*.
  78. </div>
  79. <h3>[method:Vector4 addScaledVector]( [page:Vector4 v], [page:Float s] ) [page:Vector4 this]</h3>
  80. <div>
  81. Adds the multiple of v and s to this vector.
  82. </div>
  83. <h3>[method:Vector4 sub]( [page:Vector4 v] ) [page:Vector4 this]</h3>
  84. <div>
  85. Subtracts *v* from this vector.
  86. </div>
  87. <h3>[method:Vector4 subVectors]( [page:Vector4 a], [page:Vector4 b] ) [page:Vector4 this]</h3>
  88. <div>
  89. Sets this vector to *a - b*.
  90. </div>
  91. <h3>[method:Vector4 multiplyScalar]( [page:Float s] ) [page:Vector4 this]</h3>
  92. <div>
  93. Multiplies this vector by scalar *s*.
  94. </div>
  95. <h3>[method:Vector4 divideScalar]( [page:Float s] ) [page:Vector4 this]</h3>
  96. <div>
  97. Divides this vector by scalar *s*.<br />
  98. Set vector to *( 0, 0, 0 )* if *s == 0*.
  99. </div>
  100. <h3>[method:Vector4 negate]() [page:Vector4 this]</h3>
  101. <div>
  102. Inverts this vector.
  103. </div>
  104. <h3>[method:Float dot]( [page:Vector4 v] ) [page:Vector4 this]</h3>
  105. <div>
  106. Computes dot product of this vector and *v*.
  107. </div>
  108. <h3>[method:Float lengthSq]() [page:Vector4 this]</h3>
  109. <div>
  110. Computes squared length of this vector.
  111. </div>
  112. <h3>[method:Float length]() [page:Vector4 this]</h3>
  113. <div>
  114. Computes length of this vector.
  115. </div>
  116. <h3>[method:Vector4 normalize]() [page:Vector4 this]</h3>
  117. <div>
  118. Normalizes this vector.
  119. </div>
  120. <h3>[method:Vector4 setLength]( [page:Float l] ) [page:Vector4 this]</h3>
  121. <div>
  122. Normalizes this vector and multiplies it by *l*.
  123. </div>
  124. <h3>[method:Vector4 lerp]( [page:Vector4 v], [page:Float alpha] ) [page:Vector4 this]</h3>
  125. <div>
  126. Linearly interpolate between this vector and *v* with *alpha* factor.
  127. </div>
  128. <h3>[method:Vector4 lerpVectors]( [page:Vector4 v1], [page:Vector4 v2], [page:Float alpha] ) [page:Vector4 this]</h3>
  129. <div>
  130. Sets this vector to be the vector linearly interpolated between *v1* and *v2* with *alpha* factor.
  131. </div>
  132. <h3>[method:Vector4 clamp]( [page:Vector4 min], [page:Vector4 max] ) [page:Vector4 this]</h3>
  133. <div>
  134. min -- [page:Vector4] <br />
  135. max -- [page:Vector4]
  136. </div>
  137. <div>
  138. 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/>
  139. 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 replaced by the corresponding value.
  140. </div>
  141. <h3>[method:Vector4 clampScalar]( [page:Float min], [page:Float max] ) [page:Vector4 this]</h3>
  142. <div>
  143. min -- [page:Float] the minimum value the components will be clamped to <br />
  144. max -- [page:Float] the maximum value the components will be clamped to
  145. </div>
  146. <div>
  147. If this vector's x, y, z or w values are greater than the max value, they are replaced by the max value. <br /><br />
  148. If this vector's x, y, z or w values are less than the min value, they are replaced by the min value.
  149. </div>
  150. <h3>[method:Vector4 floor]() [page:Vector4 this]</h3>
  151. <div>
  152. The components of the vector are rounded downwards (towards negative infinity) to an integer value.
  153. </div>
  154. <h3>[method:Vector4 ceil]() [page:Vector4 this]</h3>
  155. <div>
  156. The components of the vector are rounded upwards (towards positive infinity) to an integer value.
  157. </div>
  158. <h3>[method:Vector4 round]() [page:Vector4 this]</h3>
  159. <div>
  160. The components of the vector are rounded towards the nearest integer value.
  161. </div>
  162. <h3>[method:Vector4 roundToZero]() [page:Vector4 this]</h3>
  163. <div>
  164. The components of the vector are rounded towards zero (up if negative, down if positive) to an integer value.
  165. </div>
  166. <h3>[method:Vector4 applyMatrix4]( [page:Matrix4 m] ) [page:Vector4 this]</h3>
  167. <div>
  168. m -- [page:Matrix4]
  169. </div>
  170. <div>
  171. Transforms the vector by the matrix.
  172. </div>
  173. <h3>[method:Vector4 min]( [page:Vector4 v] ) [page:Vector4 this]</h3>
  174. <div>
  175. v -- [page:Vector4]
  176. </div>
  177. <div>
  178. 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.
  179. </div>
  180. <h3>[method:Vector4 max]( [page:Vector4 v] ) [page:Vector4 this]</h3>
  181. <div>
  182. v -- [page:Vector4]
  183. </div>
  184. <div>
  185. 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.
  186. </div>
  187. <h3>[method:Vector4 addScalar]( [page:Float s] ) [page:Vector4 this]</h3>
  188. <div>
  189. s -- [page:Float]
  190. </div>
  191. <div>
  192. Adds a scalar value to all of the vector's components.
  193. </div>
  194. <h3>[method:Boolean equals]( [page:Vector4 v] ) [page:Vector4 this]</h3>
  195. <div>
  196. v -- [page:Vector4]
  197. </div>
  198. <div>
  199. Checks to see if this vector matches vector v.
  200. </div>
  201. <h3>[method:Vector4 setAxisAngleFromRotationMatrix]( [page:Matrix4 m] ) [page:Vector4 this]</h3>
  202. <div>
  203. m -- [page:Matrix4]
  204. </div>
  205. <div>
  206. 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/>
  207. The axis is stored in components (x, y, z) of the vector, and the rotation in radians is stored in component w
  208. </div>
  209. <h3>[method:Vector4 setAxisAngleFromQuaternion]( [page:Quaternion q] ) [page:Vector4 this]</h3>
  210. <div>
  211. q -- [page:Quaternion]
  212. </div>
  213. <div>
  214. 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/>
  215. The axis is stored in components (x, y, z) of the vector, and the rotation in radians is stored in component w
  216. </div>
  217. <h3>[method:Float getComponent]( [page:Integer index] ) [page:Vector4 this]</h3>
  218. <div>
  219. index -- [page:Integer] 0, 1, 2, or 3
  220. </div>
  221. <div>
  222. Returns the value of the vector component x, y, or z by an index.<br/><br/>
  223. Index 0: x<br/>
  224. Index 1: y<br/>
  225. Index 2: z<br/>
  226. Index 3: w<br/>
  227. </div>
  228. <h3>[method:null setComponent]( [page:Integer index], [page:Float value] ) [page:Vector4 this]</h3>
  229. <div>
  230. index -- [page:Integer] 0 - 3 <br />
  231. value -- [page:Float]
  232. </div>
  233. <div>
  234. Sets the value of the vector component x, y, or z by an index.<br/><br/>
  235. Index 0: x<br/>
  236. Index 1: y<br/>
  237. Index 2: z<br/>
  238. Index 3: w<br/>
  239. </div>
  240. <h3>[method:Float lengthManhattan]() [page:Vector4 this]</h3>
  241. <div>
  242. Computes Manhattan length of this vector.<br />
  243. [link:http://en.wikipedia.org/wiki/Taxicab_geometry]
  244. </div>
  245. <h3>[method:Vector4 clone]() [page:Vector4 this]</h3>
  246. <div>
  247. Clones this vector.
  248. </div>
  249. <h3>[method:Array toArray]( [page:Array array], [page:Integer offset] ) [page:Vector4 this]</h3>
  250. <div>
  251. array -- An optional array to store the vector.
  252. offset -- An optional offset into the array.
  253. </div>
  254. <div>
  255. Returns an array in the format [x, y, z, w]
  256. <h2>Source</h2>
  257. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  258. </body>
  259. </html>