Vector2.html 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <h1>[name]</h1>
  2. <div class="desc">2D Vector.</div>
  3. <h2>Example</h2>
  4. <code>var a = new THREE.Vector2( 0, 1 );
  5. var b = new THREE.Vector2( 1, 0 );
  6. var d = a.distanceTo( b );
  7. </code>
  8. <h2>Constructor</h2>
  9. <h3>[name]( [page:Float x], [page:Float y] )</h3>
  10. <h2>Properties</h2>
  11. <h3>.[page:Float x]</h3>
  12. <h3>.[page:Float y]</h3>
  13. <h2>Methods</h2>
  14. <h3>.set( [page:Float x], [page:Float y] ) [page:Vector2]</h3>
  15. <div>
  16. Sets value of this vector.
  17. </div>
  18. <h3>.copy( [page:Vector2 v] ) [page:Vector2]</h3>
  19. <div>
  20. Copies value of *v* to this vector.
  21. </div>
  22. <h3>.add( [page:Vector2 a], [page:Vector2 b] ) [page:Vector2]</h3>
  23. <div>
  24. Sets this vector to *a + b*.
  25. </div>
  26. <h3>.addSelf( [page:Vector2 v] ) [page:Vector2]</h3>
  27. <div>
  28. Adds *v* to this vector.
  29. </div>
  30. <h3>.sub( [page:Vector2 a], [page:Vector2 b] ) [page:Vector2]</h3>
  31. <div>
  32. Sets this vector to *a - b*.
  33. </div>
  34. <h3>.subSelf( [page:Vector2 v] ) [page:Vector2]</h3>
  35. <div>
  36. Subtracts *v* from this vector.
  37. </div>
  38. <h3>.multiplyScalar( [page:Float s] ) [page:Vector2]</h3>
  39. <div>
  40. Multiplies this vector by scalar *s*.
  41. </div>
  42. <h3>.divideScalar( [page:Float s] ) [page:Vector2]</h3>
  43. <div>
  44. Divides this vector by scalar *s*.<br />
  45. Set vector to *( 0, 0 )* if *s == 0*.
  46. </div>
  47. <h3>.negate() [page:Vector2]</h3>
  48. <div>
  49. Inverts this vector.
  50. </div>
  51. <h3>.dot( [page:Vector2 v] ) [page:Float]</h3>
  52. <div>
  53. Computes dot product of this vector and *v*.
  54. </div>
  55. <h3>.lengthSq() [page:Float]</h3>
  56. <div>
  57. Computes squared length of this vector.
  58. </div>
  59. <h3>.length() [page:Float]</h3>
  60. <div>
  61. Computes length of this vector.
  62. </div>
  63. <h3>.normalize() [page:Vector2]</h3>
  64. <div>
  65. Normalizes this vector.
  66. </div>
  67. <h3>.distanceTo( [page:Vector2 v] ) [page:Float]</h3>
  68. <div>
  69. Computes distance of this vector to *v*.
  70. </div>
  71. <h3>.distanceToSquared( [page:Vector2 v] ) [page:Float]</h3>
  72. <div>
  73. Computes squared distance of this vector to *v*.
  74. </div>
  75. <h3>.setLength( [page:Float l] ) [page:Vector2]</h3>
  76. <div>
  77. Normalizes this vector and multiplies it by *l*.
  78. </div>
  79. <h3>.equals( [page:Vector2 v] ) [page:Vector2]</h3>
  80. <div>
  81. Checks for strict equality of this vector and *v*.
  82. </div>
  83. <h3>.isZero() [page:Boolean]</h3>
  84. <div>
  85. Checks if length of this vector is within small epsilon (*0.0001*).
  86. </div>
  87. <h3>.clone() [page:Vector2]</h3>
  88. <div>
  89. Clones this vector.
  90. </div>
  91. <h2>Source</h2>
  92. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]