Vector4.html 8.6 KB

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