source: other-projects/playing-in-the-street/summer-2013/trunk/Playing-in-the-Street-WPF/Content/Web/mrdoob-three.js-4862f5f/docs/api/math/Vector2.html@ 28897

Last change on this file since 28897 was 28897, checked in by davidb, 10 years ago

GUI front-end to server base plus web page content

File size: 5.3 KB
Line 
1<!DOCTYPE html>
2<html lang="en">
3 <head>
4 <meta charset="utf-8" />
5 <script src="../../list.js"></script>
6 <script src="../../page.js"></script>
7 <link type="text/css" rel="stylesheet" href="../../page.css" />
8 </head>
9 <body>
10 <h1>[name]</h1>
11
12 <div class="desc">2D vector.</div>
13
14 <h2>Example</h2>
15
16 <code>var a = new THREE.Vector2( 0, 1 );
17 var b = new THREE.Vector2( 1, 0 );
18
19 var d = a.distanceTo( b );
20 </code>
21
22
23 <h2>Constructor</h2>
24
25
26 <h3>[name]( [page:Float x], [page:Float y] )</h3>
27 <div>
28 x -- [page:Float] representing the x value of the vector <br />
29 y -- [page:Float] representing the y value of the vector
30 </div>
31 <div>
32 A vector in 2 dimensional space
33 </div>
34
35
36 <h2>Properties</h2>
37
38 <h3>.[page:Float x]</h3>
39
40 <h3>.[page:Float y]</h3>
41
42
43 <h2>Methods</h2>
44
45 <h3>.set( [page:Float x], [page:Float y] ) [page:Vector2 this]</h3>
46 <div>
47 Sets value of this vector.
48 </div>
49
50 <h3>.copy( [page:Vector2 v] ) [page:Vector2 this]</h3>
51 <div>
52 Copies value of *v* to this vector.
53 </div>
54
55 <h3>.add( [page:Vector2 v] ) [page:Vector2 this]</h3>
56 <div>
57 Adds *v* to this vector.
58 </div>
59
60 <h3>.addVectors( [page:Vector2 a], [page:Vector2 b] ) [page:Vector2 this]</h3>
61 <div>
62 Sets this vector to *a + b*.
63 </div>
64
65 <h3>.sub( [page:Vector2 v] ) [page:Vector2 this]</h3>
66 <div>
67 Subtracts *v* from this vector.
68 </div>
69
70 <h3>.subVectors( [page:Vector2 a], [page:Vector2 b] ) [page:Vector2 this]</h3>
71 <div>
72 Sets this vector to *a - b*.
73 </div>
74
75 <h3>.multiplyScalar( [page:Float s] ) [page:Vector2 this]</h3>
76 <div>
77 Multiplies this vector by scalar *s*.
78 </div>
79
80 <h3>.divideScalar( [page:Float s] ) [page:Vector2 this]</h3>
81 <div>
82 Divides this vector by scalar *s*.<br />
83 Set vector to *( 0, 0 )* if *s == 0*.
84 </div>
85
86 <h3>.negate() [page:Vector2 this]</h3>
87 <div>
88 Inverts this vector.
89 </div>
90
91 <h3>.dot( [page:Vector2 v] ) [page:Float]</h3>
92 <div>
93 Computes dot product of this vector and *v*.
94 </div>
95
96 <h3>.lengthSq() [page:Float]</h3>
97 <div>
98 Computes squared length of this vector.
99 </div>
100
101 <h3>.length() [page:Float]</h3>
102 <div>
103 Computes length of this vector.
104 </div>
105
106 <h3>.normalize() [page:Vector2 this]</h3>
107 <div>
108 Normalizes this vector.
109 </div>
110
111 <h3>.distanceTo( [page:Vector2 v] ) [page:Float]</h3>
112 <div>
113 Computes distance of this vector to *v*.
114 </div>
115
116 <h3>.distanceToSquared( [page:Vector2 v] ) [page:Float]</h3>
117 <div>
118 Computes squared distance of this vector to *v*.
119 </div>
120
121 <h3>.setLength( [page:Float l] ) [page:Vector2 this]</h3>
122 <div>
123 Normalizes this vector and multiplies it by *l*.
124 </div>
125
126 <h3>.equals( [page:Vector2 v] ) [page:Boolean]</h3>
127 <div>
128 Checks for strict equality of this vector and *v*.
129 </div>
130
131 <h3>.clone() [page:Vector2]</h3>
132 <div>
133 Clones this vector.
134 </div>
135
136
137 <h3>.clamp([page:Vector2 min], [page:Vector2 max]) [page:Vector2 this]</h3>
138 <div>
139 min -- [page:Vector2] containing the min x and y values in the desired range <br />
140 max -- [page:Vector2] containing the max x and y values in the desired range
141 </div>
142 <div>
143 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 /> If this vector's x or y value is less than the min vector's x or y value, it is replace by the corresponding value.
144 </div>
145
146 <h3>.lerp([page:Vector2 v], [page:Float alpha]) [page:Vector2 this]</h3>
147 <div>
148 v -- [page:Vector2] <br />
149 alpha -- [page:Float] between 0 and 1;
150 </div>
151 <div>
152 Linear interpolation between this vector and v, where alpha is the percent along the line.
153 </div>
154
155 <h3>.setComponent([page:Integer index], [page:Float value]) [page:undefined]</h3>
156 <div>
157 index -- 0 or 1 <br />
158 value -- [page:Float]
159 </div>
160 <div>
161 if index equals 0 method replaces this.x with value. <br />
162 if index equals 1 method replaces this.y with value.
163 </div>
164
165 <h3>.addScalar([page:Float s]) [page:Vector2 this]</h3>
166 <div>
167 s -- [page:Float]
168 </div>
169 <div>
170 Add the scalar value s to this vector's x and y values.
171 </div>
172
173 <h3>.getComponent([page:Integer index]) [page:Float]</h3>
174 <div>
175 index -- 0 or 1
176 </div>
177 <div>
178 if index equals 0 returns the x value. <br />
179 if index equals 1 returns the y value.
180 </div>
181
182 <h3>.fromArray([page:Array array]) [page:Vector2 this]</h3>
183 <div>
184 array -- [page:Array] of length 2
185 </div>
186 <div>
187 Sets this vector's x value to be array[0] and y value to be array[1].
188 </div>
189
190 <h3>.toArray() [page:Array]</h3>
191 <div>
192 Returns an array [x, y].
193 </div>
194
195 <h3>.min([page:Vector2 v]) [page:Vector2 this]</h3>
196 <div>
197 v -- [page:Vector2]
198 </div>
199 <div>
200 If this vector's x or y value is less than v's x or y value, replace that value with the corresponding min value.
201 </div>
202
203 <h3>.max([page:Vector2 v]) [page:Vector2 this]</h3>
204 <div>
205 v -- [page:Vector2]
206 </div>
207 <div>
208 If this vector's x or y value is greater than v's x or y value, replace that value with the corresponding max value.
209 </div>
210
211 <h3>.setX([page:Float x]) [page:Vector2 this]</h3>
212 <div>
213 x -- [page:Float]
214 </div>
215 <div>
216 replace this vector's x value with x.
217 </div>
218
219 <h3>.setY([page:Float y]) [page:Vector2 this]</h3>
220 <div>
221 y -- [page:Float]
222 </div>
223 <div>
224 replace this vector's y value with y.
225 </div>
226
227 <h2>Source</h2>
228
229 [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
230 </body>
231</html>
Note: See TracBrowser for help on using the repository browser.