forked from mrdoob/three.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVector2.html
More file actions
308 lines (252 loc) · 8.69 KB
/
Vector2.html
File metadata and controls
308 lines (252 loc) · 8.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
<!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 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>
<h3>[method:Vector2 copy]( [page:Vector2 v] ) [page:Vector2 this]</h3>
<div>
Copies value of *v* to this vector.
</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>
<div>
Sets this vector's x value to be array[0] and y value to be array[1].
</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] ) [page:Vector2 this]</h3>
<div>
Computes dot product of this vector and *v*.
</div>
<h3>[method:Float lengthSq]() [page:Vector2 this]</h3>
<div>
Computes the squared length of this vector.
</div>
<h3>[method:Float length]() [page:Vector2 this]</h3>
<div>
Computes the length of this vector.
</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 normalize]() [page:Vector2 this]</h3>
<div>
Normalizes this vector.
</div>
<h3>[method:Float angle]() [page:Vector2 this]</h3>
<div>
Computes the angle in radians of this vector with respect to the positive x-axis.
</div>
<h3>[method:Float distanceTo]( [page:Vector2 v] )</h3>
<div>
Computes the distance from this vector to *v*.
</div>
<h3>[method:Float distanceToSquared]( [page:Vector2 v] )</h3>
<div>
Computes the squared distance from this vector to *v*.
</div>
<h3>[method:Float distanceToManhattan]( [page:Vector2 v] )</h3>
<div>
Computes the Manhattan distance from 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: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 clampLength]( [page:Float min], [page:Float max] ) [page:Vector2 this]</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
</div>
<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.
</div>
<h3>[method:Vector2 floor]() [page:Vector2 this]</h3>
<div>
The components of the vector are rounded downwards (towards negative infinity) to an integer value.
</div>
<h3>[method:Vector2 ceil]() [page:Vector2 this]</h3>
<div>
The components of the vector are rounded upwards (towards positive infinity) to an integer value.
</div>
<h3>[method:Vector2 round]() [page:Vector2 this]</h3>
<div>
The components of the vector are rounded towards the nearest integer value.
</div>
<h3>[method:Vector2 roundToZero]() [page:Vector2 this]</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: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.
</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] ) [page:Vector2 this]</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 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:Boolean equals]( [page:Vector2 v] ) [page:Vector2 this]</h3>
<div>
Checks for strict equality of this vector and *v*.
</div>
<h3>[method:Vector2 clone]() [page:Vector2 this]</h3>
<div>
Clones this vector.
</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>
<div>
Returns an array [x, y].
</div>
<h2>Source</h2>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
</body>
</html>