123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8" />
- <base href="../../" />
- <script src="list.js"></script>
- <script src="page.js"></script>
- <link type="text/css" rel="stylesheet" href="page.css" />
- </head>
- <body>
- <h1>[name]</h1>
- <div class="desc">2D vector.</div>
- <h2>Example</h2>
- <code>var a = new THREE.Vector2( 0, 1 );
- var b = new THREE.Vector2( 1, 0 );
- var d = a.distanceTo( b );
- </code>
- <h2>Constructor</h2>
- <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
- </div>
- <div>
- A vector in 2 dimensional space
- </div>
- <h2>Properties</h2>
- <h3>[property:Float x]</h3>
- <h3>[property:Float y]</h3>
- <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 copy]( [page:Vector2 v] ) [page:Vector2 this]</h3>
- <div>
- Copies value of *v* to this vector.
- </div>
- <h3>[method:Vector2 add]( [page:Vector2 v] ) [page:Vector2 this]</h3>
- <div>
- Adds *v* to this vector.
- </div>
- <h3>[method:Vector2 addVectors]( [page:Vector2 a], [page:Vector2 b] ) [page:Vector2 this]</h3>
- <div>
- Sets this vector to *a + b*.
- </div>
- <h3>[method:Vector2 addScaledVector]( [page:Vector2 v], [page:Float s] ) [page:Vector2 this]</h3>
- <div>
- Adds the multiple of v and s to this vector.
- </div>
- <h3>[method:Vector2 sub]( [page:Vector2 v] ) [page:Vector2 this]</h3>
- <div>
- Subtracts *v* from this vector.
- </div>
- <h3>[method:Vector2 subVectors]( [page:Vector2 a], [page:Vector2 b] ) [page:Vector2 this]</h3>
- <div>
- Sets this vector to *a - b*.
- </div>
- <h3>[method:Vector2 multiplyScalar]( [page:Float s] ) [page:Vector2 this]</h3>
- <div>
- Multiplies this vector by scalar *s*.
- </div>
- <h3>[method:Vector2 divideScalar]( [page:Float s] ) [page:Vector2 this]</h3>
- <div>
- Divides this vector by scalar *s*.<br />
- Set vector to *( 0, 0 )* if *s == 0*.
- </div>
- <h3>[method:Vector2 negate]() [page:Vector2 this]</h3>
- <div>
- Inverts this vector.
- </div>
- <h3>[method:Float dot]( [page:Vector2 v] )</h3>
- <div>
- Computes dot product of this vector and *v*.
- </div>
- <h3>[method:Float lengthSq]()</h3>
- <div>
- Computes squared length of this vector.
- </div>
- <h3>[method:Float length]()</h3>
- <div>
- Computes length of this vector.
- </div>
- <h3>[method:Float lengthManhattan]()</h3>
- <div>
- Computes Manhattan length of this vector.<br />
- [link:http://en.wikipedia.org/wiki/Taxicab_geometry]
- </div>
- <h3>[method:Vector2 normalize]() [page:Vector2 this]</h3>
- <div>
- Normalizes this vector.
- </div>
- <h3>[method:Float distanceTo]( [page:Vector2 v] )</h3>
- <div>
- Computes distance of this vector to *v*.
- </div>
- <h3>[method:Float distanceToSquared]( [page:Vector2 v] )</h3>
- <div>
- Computes squared distance of this vector to *v*.
- </div>
- <h3>[method:Vector2 setLength]( [page:Float l] ) [page:Vector2 this]</h3>
- <div>
- Normalizes this vector and multiplies it by *l*.
- </div>
- <h3>[method:Boolean equals]( [page:Vector2 v] )</h3>
- <div>
- Checks for strict equality of this vector and *v*.
- </div>
- <h3>[method:Vector2 clone]()</h3>
- <div>
- Clones this vector.
- </div>
- <h3>[method:Vector2 clamp]([page:Vector2 min], [page:Vector2 max]) [page:Vector2 this]</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
- </div>
- <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.
- </div>
- <h3>[method:Vector2 clampScalar]([page:Float min], [page:Float max]) [page:Vector2 this]</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
- </div>
- <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.
- </div>
- <h3>[method:Vector2 floor]()</h3>
- <div>
- The components of the vector are rounded downwards (towards negative infinity) to an integer value.
- </div>
- <h3>[method:Vector2 ceil]()</h3>
- <div>
- The components of the vector are rounded upwards (towards positive infinity) to an integer value.
- </div>
- <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 lerpVectors]([page:Vector2 v1], [page:Vector2 v2], [page:Float alpha]) [page:Vector2 this]</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>
- <h3>[method:undefined setComponent]([page:Integer index], [page:Float value])</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.
- </div>
- <h3>[method:Vector2 addScalar]([page:Float s]) [page:Vector2 this]</h3>
- <div>
- s -- [page:Float]
- </div>
- <div>
- Add the scalar value s to this vector's x and y values.
- </div>
- <h3>[method:Float getComponent]([page:Integer index])</h3>
- <div>
- index -- 0 or 1
- </div>
- <div>
- if index equals 0 returns the x value. <br />
- if index equals 1 returns the y value.
- </div>
- <h3>[method:Vector2 fromArray]([page:Array array]) [page:Vector2 this]</h3>
- <div>
- array -- [page:Array] of length 2
- </div>
- <div>
- Sets this vector's x value to be array[0] and y value to be array[1].
- </div>
- <h3>[method:Array toArray]( [page:Array array] )</h3>
- <div>
- array -- Optional array to store the vector.
- </div>
- <div>
- Returns an array [x, y].
- </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 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 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 setY]([page:Float y]) [page:Vector2 this]</h3>
- <div>
- y -- [page:Float]
- </div>
- <div>
- replace this vector's y value with y.
- </div>
- <h2>Source</h2>
- [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
- </body>
- </html>
|