|
@@ -10,12 +10,38 @@
|
|
|
<body>
|
|
|
<h1>[name]</h1>
|
|
|
|
|
|
- <div class="desc">2D vector.</div>
|
|
|
+ <div class="desc">
|
|
|
+ Class representing a 2D [link:https://en.wikipedia.org/wiki/Vector_space vector].
|
|
|
+
|
|
|
+ A 2D vector is an ordered pair of numbers (labeled x and y), which can be used to
|
|
|
+ represent a number of things, such as:
|
|
|
+
|
|
|
+ <ul>
|
|
|
+ <li>
|
|
|
+ A point in 2D space (i.e. a position on a plane).
|
|
|
+ </li>
|
|
|
+ <li>
|
|
|
+ A direction and length across a plane. In Three the length will always be the
|
|
|
+ [link:https://en.wikipedia.org/wiki/Euclidean_distance Euclidean distance]
|
|
|
+ (straight-line distance) from (0, 0) to (x, y) and the direction is also
|
|
|
+ measured from (0, 0) towards (x, y).
|
|
|
+ </li>
|
|
|
+ <li>
|
|
|
+ Any arbitrary ordered pair of numbers.
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+
|
|
|
+ There are other things a 2D vector can be used to represent, such as momentum
|
|
|
+ vectors, complex numbers and so on, however these are the most common uses in Three.
|
|
|
+ </div>
|
|
|
|
|
|
<h2>Example</h2>
|
|
|
|
|
|
- <code>var a = new THREE.Vector2( 0, 1 );
|
|
|
- var b = new THREE.Vector2( 1, 0 );
|
|
|
+ <code>
|
|
|
+ var a = new THREE.Vector2( 0, 1 );
|
|
|
+
|
|
|
+ //no arguments; will be initialised to (0, 0)
|
|
|
+ var b = new THREE.Vector2( );
|
|
|
|
|
|
var d = a.distanceTo( b );
|
|
|
</code>
|
|
@@ -26,15 +52,27 @@
|
|
|
|
|
|
<h3>[name]( [page:Float x], [page:Float y] )</h3>
|
|
|
<div>
|
|
|
- x -- [page:Float] representing the x value of the vector <br />
|
|
|
- y -- [page:Float] representing the y value of the vector
|
|
|
+ [page:Float x] - the x value of the vector. Default is *0*.<br />
|
|
|
+ [page:Float y] - the y value of the vector<br /><br />
|
|
|
+
|
|
|
+ Created a new [name]
|
|
|
</div>
|
|
|
+
|
|
|
+
|
|
|
+ <h2>Properties</h2>
|
|
|
+
|
|
|
+ <h3>[property:Boolean isVector2]</h3>
|
|
|
<div>
|
|
|
- A vector in 2 dimensional space
|
|
|
+ Used to check whether this or derived classes are Vector2s. Default is *true*.<br /><br />
|
|
|
+
|
|
|
+ You should not change this, as it used internally for optimisation.
|
|
|
</div>
|
|
|
|
|
|
+ <h3>[property:Float height]</h3>
|
|
|
+ <div>Alias for [page:.y y].</div>
|
|
|
|
|
|
- <h2>Properties</h2>
|
|
|
+ <h3>[property:Float width]</h3>
|
|
|
+ <div>Alias for [page:.x x].</div>
|
|
|
|
|
|
<h3>[property:Float x]</h3>
|
|
|
|
|
@@ -43,270 +81,252 @@
|
|
|
|
|
|
<h2>Methods</h2>
|
|
|
|
|
|
- <h3>[method:Vector2 set]( [page:Float x], [page:Float y] ) [page:Vector2 this]</h3>
|
|
|
- <div>
|
|
|
- Sets value of this vector.
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector2 add]( [page:Vector2 v] )</h3>
|
|
|
+ <div>Adds [page:Vector2 v] to this vector.</div>
|
|
|
|
|
|
- <h3>[method:Vector2 setX]( [page:Float x] ) [page:Vector2 this]</h3>
|
|
|
- <div>
|
|
|
- x -- [page:Float]
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- replace this vector's x value with x.
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector2 addScalar]( [page:Float s] )</h3>
|
|
|
+ <div>Add the scalar value s to this vector's [page:.x x] and [page:.y y] values.</div>
|
|
|
|
|
|
- <h3>[method:Vector2 setY]( [page:Float y] ) [page:Vector2 this]</h3>
|
|
|
- <div>
|
|
|
- y -- [page:Float]
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- replace this vector's y value with y.
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector2 addScaledVector]( [page:Vector2 v], [page:Float s] )</h3>
|
|
|
+ <div>Adds the multiple of [page:Vector2 v] and [page:Float s] to this vector.</div>
|
|
|
|
|
|
- <h3>[method:Vector2 setScalar]( [page:Float scalar] ) [page:Vector2 this]</h3>
|
|
|
- <div>
|
|
|
- scalar -- [page:Float]
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- set all component values of this vector to *scalar*.
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector2 addVectors]( [page:Vector2 a], [page:Vector2 b] )</h3>
|
|
|
+ <div>Sets this vector to [page:Vector2 a] + [page:Vector2 b].</div>
|
|
|
|
|
|
- <h3>[method:Vector2 copy]( [page:Vector2 v] ) [page:Vector2 this]</h3>
|
|
|
+ <h3>[method:Float angle]()</h3>
|
|
|
<div>
|
|
|
- Copies value of *v* to this vector.
|
|
|
+ Computes the angle in radians of this vector with respect to the positive x-axis.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector2 fromArray]( [page:Array array], [page:Integer offset] ) [page:Vector2 this]</h3>
|
|
|
- <div>
|
|
|
- array -- The source array of length 2 <br />
|
|
|
- offset -- An optional offset into the array.
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector2 ceil]()</h3>
|
|
|
<div>
|
|
|
- Sets this vector's x value to be array[0] and y value to be array[1].
|
|
|
+ The [page:.x x] and [page:.y y] components of the vector are rounded up to the nearest integer value.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector2 add]( [page:Vector2 v] ) [page:Vector2 this]</h3>
|
|
|
+ <h3>[method:Vector2 clamp]( [page:Vector2 min], [page:Vector2 max] )</h3>
|
|
|
<div>
|
|
|
- Adds *v* to this vector.
|
|
|
- </div>
|
|
|
+ [page:Vector2 min] - the minimum x and y values.<br />
|
|
|
+ [page:Vector2 max] - the maximum x and y values in the desired range<br /><br />
|
|
|
|
|
|
- <h3>[method:Vector2 addVectors]( [page:Vector2 a], [page:Vector2 b] ) [page:Vector2 this]</h3>
|
|
|
- <div>
|
|
|
- Sets this vector to *a + b*.
|
|
|
+ If this vector's x or y value is greater than the max vector's x or y value, it is replaced by the corresponding value. <br /><br />
|
|
|
+ If this vector's x or y value is less than the min vector's x or y value, it is replaced by the corresponding value.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector2 addScaledVector]( [page:Vector2 v], [page:Float s] ) [page:Vector2 this]</h3>
|
|
|
+ <h3>[method:Vector2 clampLength]( [page:Float min], [page:Float max] )</h3>
|
|
|
<div>
|
|
|
- Adds the multiple of v and s to this vector.
|
|
|
- </div>
|
|
|
+ [page:Float min] - the minimum value the length will be clamped to <br />
|
|
|
+ [page:Float max] - the maximum value the length will be clamped to<br /><br />
|
|
|
|
|
|
- <h3>[method:Vector2 sub]( [page:Vector2 v] ) [page:Vector2 this]</h3>
|
|
|
- <div>
|
|
|
- Subtracts *v* from this vector.
|
|
|
+ If this vector's length is greater than the max value, it is replaced by the max value. <br /><br />
|
|
|
+ If this vector's length is less than the min value, it is replaced by the min value.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector2 subVectors]( [page:Vector2 a], [page:Vector2 b] ) [page:Vector2 this]</h3>
|
|
|
+ <h3>[method:Vector2 clampScalar]( [page:Float min], [page:Float max] )</h3>
|
|
|
<div>
|
|
|
- Sets this vector to *a - b*.
|
|
|
- </div>
|
|
|
+ [page:Float min] - the minimum value the components will be clamped to <br />
|
|
|
+ [page:Float max] - the maximum value the components will be clamped to<br /><br />
|
|
|
|
|
|
- <h3>[method:Vector2 multiplyScalar]( [page:Float s] ) [page:Vector2 this]</h3>
|
|
|
- <div>
|
|
|
- Multiplies this vector by scalar *s*.
|
|
|
+ If this vector's x or y values are greater than the max value, they are replaced by the max value. <br /><br />
|
|
|
+ If this vector's x or y values are less than the min value, they are replaced by the min value.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector2 divideScalar]( [page:Float s] ) [page:Vector2 this]</h3>
|
|
|
+ <h3>[method:Vector2 clone]()</h3>
|
|
|
<div>
|
|
|
- Divides this vector by scalar *s*.<br />
|
|
|
- Set vector to *( 0, 0 )* if *s == 0*.
|
|
|
+ Returns a new vector2 with the same [page:.x x] and [page:.y y] values as this one.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector2 negate]() [page:Vector2 this]</h3>
|
|
|
+ <h3>[method:Vector2 copy]( [page:Vector2 v] )</h3>
|
|
|
<div>
|
|
|
- Inverts this vector.
|
|
|
+ Copies the values of the passed vector2's [page:.x x] and [page:.y y]
|
|
|
+ properties to this vector2.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Float dot]( [page:Vector2 v] ) [page:Vector2 this]</h3>
|
|
|
- <div>
|
|
|
- Computes dot product of this vector and *v*.
|
|
|
- </div>
|
|
|
+ <h3>[method:Float distanceTo]( [page:Vector2 v] )</h3>
|
|
|
+ <div>Computes the distance from this vector to [page:Vector2 v].</div>
|
|
|
|
|
|
- <h3>[method:Float lengthSq]() [page:Vector2 this]</h3>
|
|
|
+ <h3>[method:Float distanceToManhattan]( [page:Vector2 v] )</h3>
|
|
|
<div>
|
|
|
- Computes the squared length of this vector.
|
|
|
+ Computes the [link:https://en.wikipedia.org/wiki/Taxicab_geometry Manhattan distance] from this vector to [page:Vector2 v].
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Float length]() [page:Vector2 this]</h3>
|
|
|
+ <h3>[method:Float distanceToSquared]( [page:Vector2 v] )</h3>
|
|
|
<div>
|
|
|
- Computes the length of this vector.
|
|
|
+ Computes the squared distance from this vector to [page:Vector2 v]. If you are just
|
|
|
+ comparing the distance with another distance, you should compare the distance squared instead
|
|
|
+ as it is slightly more efficient to calculate.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Float lengthManhattan]() [page:Vector2 this]</h3>
|
|
|
- <div>
|
|
|
- Computes the Manhattan length of this vector.<br />
|
|
|
- [link:http://en.wikipedia.org/wiki/Taxicab_geometry]
|
|
|
- </div>
|
|
|
+ h3>[method:Vector2 divide]( [page:Vector2 v] )</h3>
|
|
|
+ <div>Divides this vector by [page:Vector2 v].</div>
|
|
|
|
|
|
- <h3>[method:Vector2 normalize]() [page:Vector2 this]</h3>
|
|
|
+ <h3>[method:Vector2 divideScalar]( [page:Float s] )</h3>
|
|
|
<div>
|
|
|
- Normalizes this vector.
|
|
|
+ Divides this vector by scalar [page:Float s].<br />
|
|
|
+ Sets vector to *( 0, 0 )* if *[page:Float s] = 0*.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Float angle]() [page:Vector2 this]</h3>
|
|
|
+ <h3>[method:Float dot]( [page:Vector2 v] )</h3>
|
|
|
<div>
|
|
|
- Computes the angle in radians of this vector with respect to the positive x-axis.
|
|
|
+ Calculate the [link:https://en.wikipedia.org/wiki/Dot_product dot product] of this
|
|
|
+ vector and [page:Vector2 v].
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Float distanceTo]( [page:Vector2 v] )</h3>
|
|
|
- <div>
|
|
|
- Computes the distance from this vector to *v*.
|
|
|
- </div>
|
|
|
+ <h3>[method:Boolean equals]( [page:Vector2 v] )</h3>
|
|
|
+ <div>Checks for strict equality of this vector and [page:Vector2 v].</div>
|
|
|
|
|
|
- <h3>[method:Float distanceToSquared]( [page:Vector2 v] )</h3>
|
|
|
- <div>
|
|
|
- Computes the squared distance from this vector to *v*.
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector2 floor]()</h3>
|
|
|
+ <div>The components of the vector are rounded down to the nearest integer value.</div>
|
|
|
|
|
|
- <h3>[method:Float distanceToManhattan]( [page:Vector2 v] )</h3>
|
|
|
+ <h3>[method:Vector2 fromArray]( [page:Array array], [page:Integer offset] )</h3>
|
|
|
<div>
|
|
|
- Computes the Manhattan distance from this vector to *v*.
|
|
|
+ [page:Array array] - the source array.<br />
|
|
|
+ [page:Integer offset] - ( optional) offset into the array. Default is 0.<br /><br />
|
|
|
+
|
|
|
+ Sets this vector's [page:.x x] value to be array[0] and [page:.y y] value to be array[1].
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector2 setLength]( [page:Float l] ) [page:Vector2 this]</h3>
|
|
|
+ <h3>[method:Vector2 fromAttribute]( [page:BufferAttribute attribute], [page:Integer index], [page:Integer offset] )</h3>
|
|
|
<div>
|
|
|
- Normalizes this vector and multiplies it by *l*.
|
|
|
+ [page:BufferAttribute attribute] - the source attribute.<br />
|
|
|
+ [page:Integer index] - index in the attribute.<br /><br />
|
|
|
+ [page:Integer offset] - (optional) offset into the attribute. Default is 0.<br /><br />
|
|
|
+
|
|
|
+ Sets this vector's [page:.x x] and [page:.y y] values from the [page:BufferAttribute attribute].
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector2 clamp]( [page:Vector2 min], [page:Vector2 max] ) [page:Vector2 this]</h3>
|
|
|
+ <h3>[method:Float getComponent]( [page:Integer index] )</h3>
|
|
|
<div>
|
|
|
- min -- [page:Vector2] containing the min x and y values in the desired range <br />
|
|
|
- max -- [page:Vector2] containing the max x and y values in the desired range
|
|
|
+ [page:Integer index] - 0 or 1.<br /><br />
|
|
|
+
|
|
|
+ if index equals 0 returns the [page:.x x] value. <br />
|
|
|
+ if index equals 1 returns the [page:.y y] value.
|
|
|
</div>
|
|
|
+
|
|
|
+ <h3>[method:Float length]()</h3>
|
|
|
+ <div>Computes the [link:https://en.wikipedia.org/wiki/Euclidean_distance Euclidean length]
|
|
|
+ (straight-line length) from (0, 0) to (x, y).</div>
|
|
|
+
|
|
|
+ <h3>[method:Float lengthManhattan]()</h3>
|
|
|
<div>
|
|
|
- If this vector's x or y value is greater than the max vector's x or y value, it is replaced by the corresponding value. <br /><br />
|
|
|
- If this vector's x or y value is less than the min vector's x or y value, it is replaced by the corresponding value.
|
|
|
+ Computes the [link:http://en.wikipedia.org/wiki/Taxicab_geometry Manhattan length] of this vector.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector2 clampScalar]( [page:Float min], [page:Float max] ) [page:Vector2 this]</h3>
|
|
|
+ <h3>[method:Float lengthSq]()</h3>
|
|
|
<div>
|
|
|
- min -- [page:Float] the minimum value the components will be clamped to <br />
|
|
|
- max -- [page:Float] the maximum value the components will be clamped to
|
|
|
+ Computes the square of the [link:https://en.wikipedia.org/wiki/Euclidean_distance Euclidean length]
|
|
|
+ (straight-line length) from (0, 0) to (x, y). If you are comparing the lengths of
|
|
|
+ vectors, you should compare the length squared instead as it is slightly more efficient to calculate.
|
|
|
</div>
|
|
|
+
|
|
|
+ <h3>[method:Vector2 lerp]( [page:Vector2 v], [page:Float alpha] )</h3>
|
|
|
<div>
|
|
|
- If this vector's x or y values are greater than the max value, they are replaced by the max value. <br /><br />
|
|
|
- If this vector's x or y values are less than the min value, they are replaced by the min value.
|
|
|
+ [page:Vector2 v] - [page:Vector2] to interpolate towards.<br />
|
|
|
+ alpha - [page:Float] between 0 and 1<br /><br />
|
|
|
+
|
|
|
+ Linearly interpolate between this vector and [page:Vector2 v], where alpha is the
|
|
|
+ distance along the line - alpha = 0 will be this vector, and alpha = 1 will be [page:Vector2 v].
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector2 clampLength]( [page:Float min], [page:Float max] ) [page:Vector2 this]</h3>
|
|
|
+ <h3>[method:Vector2 lerpVectors]( [page:Vector2 v1], [page:Vector2 v2], [page:Float alpha] )</h3>
|
|
|
<div>
|
|
|
- min -- [page:Float] the minimum value the length will be clamped to <br />
|
|
|
- max -- [page:Float] the maximum value the length will be clamped to
|
|
|
+ [page:Vector2 v1] - the starting [page:Vector2].<br />
|
|
|
+ [page:Vector2 v2] - [page:Vector2] to interpolate towards<br />
|
|
|
+ alpha - [page:Float] between 0 and 1<br /><br />
|
|
|
+
|
|
|
+ Sets this vector to be the vector linearly interpolated between [page:Vector2 v1] and
|
|
|
+ [page:Vector2 v2] where alpha is the distance along the line connecting the two vectors
|
|
|
+ - alpha = 0 will be [page:Vector2 v1], and alpha = 1 will be [page:Vector2 v2].
|
|
|
</div>
|
|
|
+
|
|
|
+ <h3>[method:Vector2 negate]()</h3>
|
|
|
+ <div>Inverts this vector - i.e. sets x = -x and y = -y.</div>
|
|
|
+
|
|
|
+ <h3>[method:Vector2 normalize]()</h3>
|
|
|
<div>
|
|
|
- If this vector's length is greater than the max value, it is replaced by the max value. <br /><br />
|
|
|
- If this vector's length is less than the min value, it is replaced by the min value.
|
|
|
+ Normalizes this vector - that is, sets it equal to the vector with the same direction
|
|
|
+ as this one, but [page:.length length] 1.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector2 floor]() [page:Vector2 this]</h3>
|
|
|
+ <h3>[method:Vector2 max]( [page:Vector2 v] )</h3>
|
|
|
<div>
|
|
|
- The components of the vector are rounded downwards (towards negative infinity) to an integer value.
|
|
|
+ If this vector's x or y value is less than [page:Vector2 v's] x or y value, replace
|
|
|
+ that value with the corresponding max value.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector2 ceil]() [page:Vector2 this]</h3>
|
|
|
+ <h3>[method:Vector2 min]( [page:Vector2 v] )</h3>
|
|
|
<div>
|
|
|
- The components of the vector are rounded upwards (towards positive infinity) to an integer value.
|
|
|
+ If this vector's x or y value is greater than [page:Vector2 v's] x or y value, replace
|
|
|
+ that value with the corresponding min value.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector2 round]() [page:Vector2 this]</h3>
|
|
|
+ <h3>[method:Vector2 multiply]( [page:Vector2 v] )</h3>
|
|
|
+ <div>Multiplies this vector by [page:Vector2 v].</div>
|
|
|
+
|
|
|
+
|
|
|
+ <h3>[method:Vector2 multiplyScalar]( [page:Float s] )</h3>
|
|
|
+ <div>Multiplies this vector by scalar [page:Float s].</div>
|
|
|
+
|
|
|
+ <h3>[method:Vector2 rotateAround]( [page:Vector2 center], [page:float angle] )</h3>
|
|
|
<div>
|
|
|
- The components of the vector are rounded towards the nearest integer value.
|
|
|
+ [page:Vector2 center] - the point around which to rotate.<br />
|
|
|
+ [page:float angle] - the angle to rotate, in radians.<br /><br />
|
|
|
+
|
|
|
+ Rotate the vector arounf [page:Vector2 center] by [page:float angle] radians.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector2 roundToZero]() [page:Vector2 this]</h3>
|
|
|
+ <h3>[method:Vector2 round]()</h3>
|
|
|
+ <div>The components of the vector are rounded towards the nearest integer value.</div>
|
|
|
+
|
|
|
+ <h3>[method:Vector2 roundToZero]()</h3>
|
|
|
<div>
|
|
|
The components of the vector are rounded towards zero (up if negative, down if positive) to an integer value.
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector2 lerp]( [page:Vector2 v], [page:Float alpha] ) [page:Vector2 this]</h3>
|
|
|
- <div>
|
|
|
- v -- [page:Vector2] <br />
|
|
|
- alpha -- [page:Float] between 0 and 1;
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- Linear interpolation between this vector and v, where alpha is the percent along the line.
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector2 set]( [page:Float x], [page:Float y] )</h3>
|
|
|
+ <div>Sets the [page:.x x] and [page:.y y] components of this vector.</div>
|
|
|
|
|
|
- <h3>[method:Vector2 lerpVectors]( [page:Vector2 v1], [page:Vector2 v2], [page:Float alpha] ) [page:Vector2 this]</h3>
|
|
|
+ <h3>[method:null setComponent]( [page:Integer index], [page:Float value] )</h3>
|
|
|
<div>
|
|
|
- v1 -- [page:Vector2] <br />
|
|
|
- v2 -- [page:Vector2] <br />
|
|
|
- alpha -- [page:Float] between 0 and 1.
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- Sets this vector to be the vector linearly interpolated between *v1* and *v2* with *alpha* factor.
|
|
|
- </div>
|
|
|
+ [page:Integer index] - 0 or 1.<br />
|
|
|
+ [page:Float value] - [page:Float]<br /><br />
|
|
|
|
|
|
- <h3>[method:null setComponent]( [page:Integer index], [page:Float value] ) [page:Vector2 this]</h3>
|
|
|
- <div>
|
|
|
- index -- 0 or 1 <br />
|
|
|
- value -- [page:Float]
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- if index equals 0 method replaces this.x with value. <br />
|
|
|
- if index equals 1 method replaces this.y with value.
|
|
|
+ if index equals 0 method replaces [page:.x x] with [page:Float value]. <br />
|
|
|
+ if index equals 1 method replaces [page:.y y] with [page:Float value]
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector2 addScalar]( [page:Float s] ) [page:Vector2 this]</h3>
|
|
|
+ <h3>[method:Vector2 setLength]( [page:Float l] )</h3>
|
|
|
<div>
|
|
|
- s -- [page:Float]
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- Add the scalar value s to this vector's x and y values.
|
|
|
+ Set this vector to the vector with the same direction as this one, but [page:.length length]
|
|
|
+ [page:Float l].
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Float getComponent]( [page:Integer index] ) [page:Vector2 this]</h3>
|
|
|
- <div>
|
|
|
- index -- 0 or 1
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector2 setScalar]( [page:Float scalar] )</h3>
|
|
|
<div>
|
|
|
- if index equals 0 returns the x value. <br />
|
|
|
- if index equals 1 returns the y value.
|
|
|
+ Set the [page:.x x] and [page:.y y] values of this vector both equal to [page:Float scalar].
|
|
|
</div>
|
|
|
|
|
|
- <h3>[method:Vector2 min]( [page:Vector2 v] ) [page:Vector2 this]</h3>
|
|
|
- <div>
|
|
|
- v -- [page:Vector2]
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- If this vector's x or y value is greater than v's x or y value, replace that value with the corresponding min value.
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector2 setX]( [page:Float x] )</h3>
|
|
|
+ <div>Replace this vector's [page:.x x] value with [page:Float x].</div>
|
|
|
|
|
|
- <h3>[method:Vector2 max]( [page:Vector2 v] ) [page:Vector2 this]</h3>
|
|
|
- <div>
|
|
|
- v -- [page:Vector2]
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- If this vector's x or y value is less than v's x or y value, replace that value with the corresponding max value.
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector2 setY]( [page:Float y] )</h3>
|
|
|
+ <div>Replace this vector's [page:.y y] value with [page:Float y].</div>
|
|
|
|
|
|
- <h3>[method:Boolean equals]( [page:Vector2 v] ) [page:Vector2 this]</h3>
|
|
|
- <div>
|
|
|
- Checks for strict equality of this vector and *v*.
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector2 sub]( [page:Vector2 v] )</h3>
|
|
|
+ <div>Subtracts [page:Vector2 v] from this vector.</div>
|
|
|
|
|
|
- <h3>[method:Vector2 clone]() [page:Vector2 this]</h3>
|
|
|
- <div>
|
|
|
- Clones this vector.
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector2 subScalar]( [page:Float s] )</h3>
|
|
|
+ <div>Subtracts [page:Float s] from this vector's [page:.x x] and [page:.y y] compnents.</div>
|
|
|
|
|
|
- <h3>[method:Array toArray]( [page:Array array], [page:Integer offset] ) [page:Vector2 this]</h3>
|
|
|
- <div>
|
|
|
- array -- An optional array to store the vector to. <br />
|
|
|
- offset -- An optional offset into the array.
|
|
|
- </div>
|
|
|
+ <h3>[method:Vector2 subVectors]( [page:Vector2 a], [page:Vector2 b] )</h3>
|
|
|
+ <div>Sets this vector to [page:Vector2 a] - [page:Vector2 b].</div>
|
|
|
+
|
|
|
+ <h3>[method:Array toArray]( [page:Array array], [page:Integer offset] )</h3>
|
|
|
<div>
|
|
|
- Returns an array [x, y].
|
|
|
+ [page:Array array] - (optional) array to store the vector to. If this is not provided
|
|
|
+ a new array will be created.<br />
|
|
|
+ [page:Integer offset] - (optional) optional offset into the array.<br /><br />
|
|
|
+
|
|
|
+ Returns an array [x, y], or copies x and y into the provided [page:Array array].
|
|
|
</div>
|
|
|
|
|
|
<h2>Source</h2>
|