Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Vector2.cs
Go to the documentation of this file.
1using System;
5using Microsoft.Xna.Framework.Design;
6
8
10[TypeConverter(typeof(Vector2Converter))]
11public struct Vector2 : IEquatable<Vector2>
12{
13 [SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")]
14 public float X;
15
16 [SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")]
17 public float Y;
18
19 private static Vector2 _zero = default(Vector2);
20
21 private static Vector2 _one = new Vector2(1f, 1f);
22
23 private static Vector2 _unitX = new Vector2(1f, 0f);
24
25 private static Vector2 _unitY = new Vector2(0f, 1f);
26
27 public static Vector2 Zero => _zero;
28
29 public static Vector2 One => _one;
30
31 public static Vector2 UnitX => _unitX;
32
33 public static Vector2 UnitY => _unitY;
34
35 public Vector2(float x, float y)
36 {
37 X = x;
38 Y = y;
39 }
40
41 public Vector2(float value)
42 {
43 X = (Y = value);
44 }
45
46 public override string ToString()
47 {
48 CultureInfo currentCulture = CultureInfo.CurrentCulture;
49 return string.Format(currentCulture, "{{X:{0} Y:{1}}}", new object[2]
50 {
51 X.ToString(currentCulture),
52 Y.ToString(currentCulture)
53 });
54 }
55
56 public bool Equals(Vector2 other)
57 {
58 if (X == other.X)
59 {
60 return Y == other.Y;
61 }
62 return false;
63 }
64
65 public override bool Equals(object obj)
66 {
67 bool result = false;
68 if (obj is Vector2)
69 {
70 result = Equals((Vector2)obj);
71 }
72 return result;
73 }
74
75 public override int GetHashCode()
76 {
77 return X.GetHashCode() + Y.GetHashCode();
78 }
79
80 public float Length()
81 {
82 float num = X * X + Y * Y;
83 return (float)Math.Sqrt(num);
84 }
85
86 public float LengthSquared()
87 {
88 return X * X + Y * Y;
89 }
90
91 public static float Distance(Vector2 value1, Vector2 value2)
92 {
93 float num = value1.X - value2.X;
94 float num2 = value1.Y - value2.Y;
95 float num3 = num * num + num2 * num2;
96 return (float)Math.Sqrt(num3);
97 }
98
99 public static void Distance(ref Vector2 value1, ref Vector2 value2, out float result)
100 {
101 float num = value1.X - value2.X;
102 float num2 = value1.Y - value2.Y;
103 float num3 = num * num + num2 * num2;
104 result = (float)Math.Sqrt(num3);
105 }
106
107 public static float DistanceSquared(Vector2 value1, Vector2 value2)
108 {
109 float num = value1.X - value2.X;
110 float num2 = value1.Y - value2.Y;
111 return num * num + num2 * num2;
112 }
113
114 public static void DistanceSquared(ref Vector2 value1, ref Vector2 value2, out float result)
115 {
116 float num = value1.X - value2.X;
117 float num2 = value1.Y - value2.Y;
118 result = num * num + num2 * num2;
119 }
120
121 public static float Dot(Vector2 value1, Vector2 value2)
122 {
123 return value1.X * value2.X + value1.Y * value2.Y;
124 }
125
126 public static void Dot(ref Vector2 value1, ref Vector2 value2, out float result)
127 {
128 result = value1.X * value2.X + value1.Y * value2.Y;
129 }
130
131 public void Normalize()
132 {
133 float num = X * X + Y * Y;
134 float num2 = 1f / (float)Math.Sqrt(num);
135 X *= num2;
136 Y *= num2;
137 }
138
140 {
141 float num = value.X * value.X + value.Y * value.Y;
142 float num2 = 1f / (float)Math.Sqrt(num);
143 Vector2 result = default(Vector2);
144 result.X = value.X * num2;
145 result.Y = value.Y * num2;
146 return result;
147 }
148
149 public static void Normalize(ref Vector2 value, out Vector2 result)
150 {
151 float num = value.X * value.X + value.Y * value.Y;
152 float num2 = 1f / (float)Math.Sqrt(num);
153 result.X = value.X * num2;
154 result.Y = value.Y * num2;
155 }
156
157 public static Vector2 Reflect(Vector2 vector, Vector2 normal)
158 {
159 float num = vector.X * normal.X + vector.Y * normal.Y;
160 Vector2 result = default(Vector2);
161 result.X = vector.X - 2f * num * normal.X;
162 result.Y = vector.Y - 2f * num * normal.Y;
163 return result;
164 }
165
166 public static void Reflect(ref Vector2 vector, ref Vector2 normal, out Vector2 result)
167 {
168 float num = vector.X * normal.X + vector.Y * normal.Y;
169 result.X = vector.X - 2f * num * normal.X;
170 result.Y = vector.Y - 2f * num * normal.Y;
171 }
172
173 public static Vector2 Min(Vector2 value1, Vector2 value2)
174 {
175 Vector2 result = default(Vector2);
176 result.X = ((value1.X < value2.X) ? value1.X : value2.X);
177 result.Y = ((value1.Y < value2.Y) ? value1.Y : value2.Y);
178 return result;
179 }
180
181 public static void Min(ref Vector2 value1, ref Vector2 value2, out Vector2 result)
182 {
183 result.X = ((value1.X < value2.X) ? value1.X : value2.X);
184 result.Y = ((value1.Y < value2.Y) ? value1.Y : value2.Y);
185 }
186
187 public static Vector2 Max(Vector2 value1, Vector2 value2)
188 {
189 Vector2 result = default(Vector2);
190 result.X = ((value1.X > value2.X) ? value1.X : value2.X);
191 result.Y = ((value1.Y > value2.Y) ? value1.Y : value2.Y);
192 return result;
193 }
194
195 public static void Max(ref Vector2 value1, ref Vector2 value2, out Vector2 result)
196 {
197 result.X = ((value1.X > value2.X) ? value1.X : value2.X);
198 result.Y = ((value1.Y > value2.Y) ? value1.Y : value2.Y);
199 }
200
201 public static Vector2 Clamp(Vector2 value1, Vector2 min, Vector2 max)
202 {
203 float x = value1.X;
204 x = ((x > max.X) ? max.X : x);
205 x = ((x < min.X) ? min.X : x);
206 float y = value1.Y;
207 y = ((y > max.Y) ? max.Y : y);
208 y = ((y < min.Y) ? min.Y : y);
209 Vector2 result = default(Vector2);
210 result.X = x;
211 result.Y = y;
212 return result;
213 }
214
215 public static void Clamp(ref Vector2 value1, ref Vector2 min, ref Vector2 max, out Vector2 result)
216 {
217 float x = value1.X;
218 x = ((x > max.X) ? max.X : x);
219 x = ((x < min.X) ? min.X : x);
220 float y = value1.Y;
221 y = ((y > max.Y) ? max.Y : y);
222 y = ((y < min.Y) ? min.Y : y);
223 result.X = x;
224 result.Y = y;
225 }
226
227 public static Vector2 Lerp(Vector2 value1, Vector2 value2, float amount)
228 {
229 Vector2 result = default(Vector2);
230 result.X = value1.X + (value2.X - value1.X) * amount;
231 result.Y = value1.Y + (value2.Y - value1.Y) * amount;
232 return result;
233 }
234
235 public static void Lerp(ref Vector2 value1, ref Vector2 value2, float amount, out Vector2 result)
236 {
237 result.X = value1.X + (value2.X - value1.X) * amount;
238 result.Y = value1.Y + (value2.Y - value1.Y) * amount;
239 }
240
241 public static Vector2 Barycentric(Vector2 value1, Vector2 value2, Vector2 value3, float amount1, float amount2)
242 {
243 Vector2 result = default(Vector2);
244 result.X = value1.X + amount1 * (value2.X - value1.X) + amount2 * (value3.X - value1.X);
245 result.Y = value1.Y + amount1 * (value2.Y - value1.Y) + amount2 * (value3.Y - value1.Y);
246 return result;
247 }
248
249 public static void Barycentric(ref Vector2 value1, ref Vector2 value2, ref Vector2 value3, float amount1, float amount2, out Vector2 result)
250 {
251 result.X = value1.X + amount1 * (value2.X - value1.X) + amount2 * (value3.X - value1.X);
252 result.Y = value1.Y + amount1 * (value2.Y - value1.Y) + amount2 * (value3.Y - value1.Y);
253 }
254
255 public static Vector2 SmoothStep(Vector2 value1, Vector2 value2, float amount)
256 {
257 amount = ((amount > 1f) ? 1f : ((amount < 0f) ? 0f : amount));
258 amount = amount * amount * (3f - 2f * amount);
259 Vector2 result = default(Vector2);
260 result.X = value1.X + (value2.X - value1.X) * amount;
261 result.Y = value1.Y + (value2.Y - value1.Y) * amount;
262 return result;
263 }
264
265 public static void SmoothStep(ref Vector2 value1, ref Vector2 value2, float amount, out Vector2 result)
266 {
267 amount = ((amount > 1f) ? 1f : ((amount < 0f) ? 0f : amount));
268 amount = amount * amount * (3f - 2f * amount);
269 result.X = value1.X + (value2.X - value1.X) * amount;
270 result.Y = value1.Y + (value2.Y - value1.Y) * amount;
271 }
272
273 public static Vector2 CatmullRom(Vector2 value1, Vector2 value2, Vector2 value3, Vector2 value4, float amount)
274 {
275 float num = amount * amount;
276 float num2 = amount * num;
277 Vector2 result = default(Vector2);
278 result.X = 0.5f * (2f * value2.X + (0f - value1.X + value3.X) * amount + (2f * value1.X - 5f * value2.X + 4f * value3.X - value4.X) * num + (0f - value1.X + 3f * value2.X - 3f * value3.X + value4.X) * num2);
279 result.Y = 0.5f * (2f * value2.Y + (0f - value1.Y + value3.Y) * amount + (2f * value1.Y - 5f * value2.Y + 4f * value3.Y - value4.Y) * num + (0f - value1.Y + 3f * value2.Y - 3f * value3.Y + value4.Y) * num2);
280 return result;
281 }
282
283 public static void CatmullRom(ref Vector2 value1, ref Vector2 value2, ref Vector2 value3, ref Vector2 value4, float amount, out Vector2 result)
284 {
285 float num = amount * amount;
286 float num2 = amount * num;
287 result.X = 0.5f * (2f * value2.X + (0f - value1.X + value3.X) * amount + (2f * value1.X - 5f * value2.X + 4f * value3.X - value4.X) * num + (0f - value1.X + 3f * value2.X - 3f * value3.X + value4.X) * num2);
288 result.Y = 0.5f * (2f * value2.Y + (0f - value1.Y + value3.Y) * amount + (2f * value1.Y - 5f * value2.Y + 4f * value3.Y - value4.Y) * num + (0f - value1.Y + 3f * value2.Y - 3f * value3.Y + value4.Y) * num2);
289 }
290
291 public static Vector2 Hermite(Vector2 value1, Vector2 tangent1, Vector2 value2, Vector2 tangent2, float amount)
292 {
293 float num = amount * amount;
294 float num2 = amount * num;
295 float num3 = 2f * num2 - 3f * num + 1f;
296 float num4 = -2f * num2 + 3f * num;
297 float num5 = num2 - 2f * num + amount;
298 float num6 = num2 - num;
299 Vector2 result = default(Vector2);
300 result.X = value1.X * num3 + value2.X * num4 + tangent1.X * num5 + tangent2.X * num6;
301 result.Y = value1.Y * num3 + value2.Y * num4 + tangent1.Y * num5 + tangent2.Y * num6;
302 return result;
303 }
304
305 public static void Hermite(ref Vector2 value1, ref Vector2 tangent1, ref Vector2 value2, ref Vector2 tangent2, float amount, out Vector2 result)
306 {
307 float num = amount * amount;
308 float num2 = amount * num;
309 float num3 = 2f * num2 - 3f * num + 1f;
310 float num4 = -2f * num2 + 3f * num;
311 float num5 = num2 - 2f * num + amount;
312 float num6 = num2 - num;
313 result.X = value1.X * num3 + value2.X * num4 + tangent1.X * num5 + tangent2.X * num6;
314 result.Y = value1.Y * num3 + value2.Y * num4 + tangent1.Y * num5 + tangent2.Y * num6;
315 }
316
317 public static Vector2 Transform(Vector2 position, Matrix matrix)
318 {
319 float x = position.X * matrix.M11 + position.Y * matrix.M21 + matrix.M41;
320 float y = position.X * matrix.M12 + position.Y * matrix.M22 + matrix.M42;
321 Vector2 result = default(Vector2);
322 result.X = x;
323 result.Y = y;
324 return result;
325 }
326
327 public static void Transform(ref Vector2 position, ref Matrix matrix, out Vector2 result)
328 {
329 float x = position.X * matrix.M11 + position.Y * matrix.M21 + matrix.M41;
330 float y = position.X * matrix.M12 + position.Y * matrix.M22 + matrix.M42;
331 result.X = x;
332 result.Y = y;
333 }
334
335 public static Vector2 TransformNormal(Vector2 normal, Matrix matrix)
336 {
337 float x = normal.X * matrix.M11 + normal.Y * matrix.M21;
338 float y = normal.X * matrix.M12 + normal.Y * matrix.M22;
339 Vector2 result = default(Vector2);
340 result.X = x;
341 result.Y = y;
342 return result;
343 }
344
345 public static void TransformNormal(ref Vector2 normal, ref Matrix matrix, out Vector2 result)
346 {
347 float x = normal.X * matrix.M11 + normal.Y * matrix.M21;
348 float y = normal.X * matrix.M12 + normal.Y * matrix.M22;
349 result.X = x;
350 result.Y = y;
351 }
352
353 public static Vector2 Transform(Vector2 value, Quaternion rotation)
354 {
355 float num = rotation.X + rotation.X;
356 float num2 = rotation.Y + rotation.Y;
357 float num3 = rotation.Z + rotation.Z;
358 float num4 = rotation.W * num3;
359 float num5 = rotation.X * num;
360 float num6 = rotation.X * num2;
361 float num7 = rotation.Y * num2;
362 float num8 = rotation.Z * num3;
363 float x = value.X * (1f - num7 - num8) + value.Y * (num6 - num4);
364 float y = value.X * (num6 + num4) + value.Y * (1f - num5 - num8);
365 Vector2 result = default(Vector2);
366 result.X = x;
367 result.Y = y;
368 return result;
369 }
370
371 public static void Transform(ref Vector2 value, ref Quaternion rotation, out Vector2 result)
372 {
373 float num = rotation.X + rotation.X;
374 float num2 = rotation.Y + rotation.Y;
375 float num3 = rotation.Z + rotation.Z;
376 float num4 = rotation.W * num3;
377 float num5 = rotation.X * num;
378 float num6 = rotation.X * num2;
379 float num7 = rotation.Y * num2;
380 float num8 = rotation.Z * num3;
381 float x = value.X * (1f - num7 - num8) + value.Y * (num6 - num4);
382 float y = value.X * (num6 + num4) + value.Y * (1f - num5 - num8);
383 result.X = x;
384 result.Y = y;
385 }
386
387 public static void Transform(Vector2[] sourceArray, ref Matrix matrix, Vector2[] destinationArray)
388 {
389 if (sourceArray == null)
390 {
391 throw new ArgumentNullException("sourceArray");
392 }
393 if (destinationArray == null)
394 {
395 throw new ArgumentNullException("destinationArray");
396 }
397 if (destinationArray.Length < sourceArray.Length)
398 {
400 }
401 for (int i = 0; i < sourceArray.Length; i++)
402 {
403 float x = sourceArray[i].X;
404 float y = sourceArray[i].Y;
405 destinationArray[i].X = x * matrix.M11 + y * matrix.M21 + matrix.M41;
406 destinationArray[i].Y = x * matrix.M12 + y * matrix.M22 + matrix.M42;
407 }
408 }
409
410 [SuppressMessage("Microsoft.Usage", "CA2233")]
412 {
413 if (sourceArray == null)
414 {
415 throw new ArgumentNullException("sourceArray");
416 }
417 if (destinationArray == null)
418 {
419 throw new ArgumentNullException("destinationArray");
420 }
421 if (sourceArray.Length < (long)sourceIndex + (long)length)
422 {
424 }
425 if (destinationArray.Length < (long)destinationIndex + (long)length)
426 {
428 }
429 while (length > 0)
430 {
431 float x = sourceArray[sourceIndex].X;
432 float y = sourceArray[sourceIndex].Y;
433 destinationArray[destinationIndex].X = x * matrix.M11 + y * matrix.M21 + matrix.M41;
434 destinationArray[destinationIndex].Y = x * matrix.M12 + y * matrix.M22 + matrix.M42;
435 sourceIndex++;
437 length--;
438 }
439 }
440
442 {
443 if (sourceArray == null)
444 {
445 throw new ArgumentNullException("sourceArray");
446 }
447 if (destinationArray == null)
448 {
449 throw new ArgumentNullException("destinationArray");
450 }
451 if (destinationArray.Length < sourceArray.Length)
452 {
454 }
455 for (int i = 0; i < sourceArray.Length; i++)
456 {
457 float x = sourceArray[i].X;
458 float y = sourceArray[i].Y;
459 destinationArray[i].X = x * matrix.M11 + y * matrix.M21;
460 destinationArray[i].Y = x * matrix.M12 + y * matrix.M22;
461 }
462 }
463
464 [SuppressMessage("Microsoft.Usage", "CA2233")]
466 {
467 if (sourceArray == null)
468 {
469 throw new ArgumentNullException("sourceArray");
470 }
471 if (destinationArray == null)
472 {
473 throw new ArgumentNullException("destinationArray");
474 }
475 if (sourceArray.Length < (long)sourceIndex + (long)length)
476 {
478 }
479 if (destinationArray.Length < (long)destinationIndex + (long)length)
480 {
482 }
483 while (length > 0)
484 {
485 float x = sourceArray[sourceIndex].X;
486 float y = sourceArray[sourceIndex].Y;
487 destinationArray[destinationIndex].X = x * matrix.M11 + y * matrix.M21;
488 destinationArray[destinationIndex].Y = x * matrix.M12 + y * matrix.M22;
489 sourceIndex++;
491 length--;
492 }
493 }
494
495 public static void Transform(Vector2[] sourceArray, ref Quaternion rotation, Vector2[] destinationArray)
496 {
497 if (sourceArray == null)
498 {
499 throw new ArgumentNullException("sourceArray");
500 }
501 if (destinationArray == null)
502 {
503 throw new ArgumentNullException("destinationArray");
504 }
505 if (destinationArray.Length < sourceArray.Length)
506 {
508 }
509 float num = rotation.X + rotation.X;
510 float num2 = rotation.Y + rotation.Y;
511 float num3 = rotation.Z + rotation.Z;
512 float num4 = rotation.W * num3;
513 float num5 = rotation.X * num;
514 float num6 = rotation.X * num2;
515 float num7 = rotation.Y * num2;
516 float num8 = rotation.Z * num3;
517 float num9 = 1f - num7 - num8;
518 float num10 = num6 - num4;
519 float num11 = num6 + num4;
520 float num12 = 1f - num5 - num8;
521 for (int i = 0; i < sourceArray.Length; i++)
522 {
523 float x = sourceArray[i].X;
524 float y = sourceArray[i].Y;
525 destinationArray[i].X = x * num9 + y * num10;
526 destinationArray[i].Y = x * num11 + y * num12;
527 }
528 }
529
530 [SuppressMessage("Microsoft.Usage", "CA2233")]
532 {
533 if (sourceArray == null)
534 {
535 throw new ArgumentNullException("sourceArray");
536 }
537 if (destinationArray == null)
538 {
539 throw new ArgumentNullException("destinationArray");
540 }
541 if (sourceArray.Length < (long)sourceIndex + (long)length)
542 {
544 }
545 if (destinationArray.Length < (long)destinationIndex + (long)length)
546 {
548 }
549 float num = rotation.X + rotation.X;
550 float num2 = rotation.Y + rotation.Y;
551 float num3 = rotation.Z + rotation.Z;
552 float num4 = rotation.W * num3;
553 float num5 = rotation.X * num;
554 float num6 = rotation.X * num2;
555 float num7 = rotation.Y * num2;
556 float num8 = rotation.Z * num3;
557 float num9 = 1f - num7 - num8;
558 float num10 = num6 - num4;
559 float num11 = num6 + num4;
560 float num12 = 1f - num5 - num8;
561 while (length > 0)
562 {
563 float x = sourceArray[sourceIndex].X;
564 float y = sourceArray[sourceIndex].Y;
565 destinationArray[destinationIndex].X = x * num9 + y * num10;
566 destinationArray[destinationIndex].Y = x * num11 + y * num12;
567 sourceIndex++;
569 length--;
570 }
571 }
572
574 {
575 Vector2 result = default(Vector2);
576 result.X = 0f - value.X;
577 result.Y = 0f - value.Y;
578 return result;
579 }
580
581 public static void Negate(ref Vector2 value, out Vector2 result)
582 {
583 result.X = 0f - value.X;
584 result.Y = 0f - value.Y;
585 }
586
587 public static Vector2 Add(Vector2 value1, Vector2 value2)
588 {
589 Vector2 result = default(Vector2);
590 result.X = value1.X + value2.X;
591 result.Y = value1.Y + value2.Y;
592 return result;
593 }
594
595 public static void Add(ref Vector2 value1, ref Vector2 value2, out Vector2 result)
596 {
597 result.X = value1.X + value2.X;
598 result.Y = value1.Y + value2.Y;
599 }
600
601 public static Vector2 Subtract(Vector2 value1, Vector2 value2)
602 {
603 Vector2 result = default(Vector2);
604 result.X = value1.X - value2.X;
605 result.Y = value1.Y - value2.Y;
606 return result;
607 }
608
609 public static void Subtract(ref Vector2 value1, ref Vector2 value2, out Vector2 result)
610 {
611 result.X = value1.X - value2.X;
612 result.Y = value1.Y - value2.Y;
613 }
614
615 public static Vector2 Multiply(Vector2 value1, Vector2 value2)
616 {
617 Vector2 result = default(Vector2);
618 result.X = value1.X * value2.X;
619 result.Y = value1.Y * value2.Y;
620 return result;
621 }
622
623 public static void Multiply(ref Vector2 value1, ref Vector2 value2, out Vector2 result)
624 {
625 result.X = value1.X * value2.X;
626 result.Y = value1.Y * value2.Y;
627 }
628
629 public static Vector2 Multiply(Vector2 value1, float scaleFactor)
630 {
631 Vector2 result = default(Vector2);
632 result.X = value1.X * scaleFactor;
633 result.Y = value1.Y * scaleFactor;
634 return result;
635 }
636
637 public static void Multiply(ref Vector2 value1, float scaleFactor, out Vector2 result)
638 {
639 result.X = value1.X * scaleFactor;
640 result.Y = value1.Y * scaleFactor;
641 }
642
643 public static Vector2 Divide(Vector2 value1, Vector2 value2)
644 {
645 Vector2 result = default(Vector2);
646 result.X = value1.X / value2.X;
647 result.Y = value1.Y / value2.Y;
648 return result;
649 }
650
651 public static void Divide(ref Vector2 value1, ref Vector2 value2, out Vector2 result)
652 {
653 result.X = value1.X / value2.X;
654 result.Y = value1.Y / value2.Y;
655 }
656
657 public static Vector2 Divide(Vector2 value1, float divider)
658 {
659 float num = 1f / divider;
660 Vector2 result = default(Vector2);
661 result.X = value1.X * num;
662 result.Y = value1.Y * num;
663 return result;
664 }
665
666 public static void Divide(ref Vector2 value1, float divider, out Vector2 result)
667 {
668 float num = 1f / divider;
669 result.X = value1.X * num;
670 result.Y = value1.Y * num;
671 }
672
674 {
675 Vector2 result = default(Vector2);
676 result.X = 0f - value.X;
677 result.Y = 0f - value.Y;
678 return result;
679 }
680
681 public static bool operator ==(Vector2 value1, Vector2 value2)
682 {
683 if (value1.X == value2.X)
684 {
685 return value1.Y == value2.Y;
686 }
687 return false;
688 }
689
690 public static bool operator !=(Vector2 value1, Vector2 value2)
691 {
692 if (value1.X == value2.X)
693 {
694 return value1.Y != value2.Y;
695 }
696 return true;
697 }
698
699 public static Vector2 operator +(Vector2 value1, Vector2 value2)
700 {
701 Vector2 result = default(Vector2);
702 result.X = value1.X + value2.X;
703 result.Y = value1.Y + value2.Y;
704 return result;
705 }
706
707 public static Vector2 operator -(Vector2 value1, Vector2 value2)
708 {
709 Vector2 result = default(Vector2);
710 result.X = value1.X - value2.X;
711 result.Y = value1.Y - value2.Y;
712 return result;
713 }
714
715 public static Vector2 operator *(Vector2 value1, Vector2 value2)
716 {
717 Vector2 result = default(Vector2);
718 result.X = value1.X * value2.X;
719 result.Y = value1.Y * value2.Y;
720 return result;
721 }
722
723 public static Vector2 operator *(Vector2 value, float scaleFactor)
724 {
725 Vector2 result = default(Vector2);
726 result.X = value.X * scaleFactor;
727 result.Y = value.Y * scaleFactor;
728 return result;
729 }
730
731 public static Vector2 operator *(float scaleFactor, Vector2 value)
732 {
733 Vector2 result = default(Vector2);
734 result.X = value.X * scaleFactor;
735 result.Y = value.Y * scaleFactor;
736 return result;
737 }
738
739 public static Vector2 operator /(Vector2 value1, Vector2 value2)
740 {
741 Vector2 result = default(Vector2);
742 result.X = value1.X / value2.X;
743 result.Y = value1.Y / value2.Y;
744 return result;
745 }
746
747 public static Vector2 operator /(Vector2 value1, float divider)
748 {
749 float num = 1f / divider;
750 Vector2 result = default(Vector2);
751 result.X = value1.X * num;
752 result.Y = value1.Y * num;
753 return result;
754 }
755}
static CultureInfo CurrentCulture
static double Sqrt(double d)
bool Equals(Vector2 other)
Definition Vector2.cs:56
static void Multiply(ref Vector2 value1, ref Vector2 value2, out Vector2 result)
Definition Vector2.cs:623
static Vector2 Divide(Vector2 value1, float divider)
Definition Vector2.cs:657
static void CatmullRom(ref Vector2 value1, ref Vector2 value2, ref Vector2 value3, ref Vector2 value4, float amount, out Vector2 result)
Definition Vector2.cs:283
override bool Equals(object obj)
Definition Vector2.cs:65
static float Dot(Vector2 value1, Vector2 value2)
Definition Vector2.cs:121
static Vector2 operator*(Vector2 value1, Vector2 value2)
Definition Vector2.cs:715
static void Multiply(ref Vector2 value1, float scaleFactor, out Vector2 result)
Definition Vector2.cs:637
static void TransformNormal(ref Vector2 normal, ref Matrix matrix, out Vector2 result)
Definition Vector2.cs:345
static Vector2 Negate(Vector2 value)
Definition Vector2.cs:573
static Vector2 Clamp(Vector2 value1, Vector2 min, Vector2 max)
Definition Vector2.cs:201
static Vector2 Reflect(Vector2 vector, Vector2 normal)
Definition Vector2.cs:157
static Vector2 Multiply(Vector2 value1, float scaleFactor)
Definition Vector2.cs:629
static void DistanceSquared(ref Vector2 value1, ref Vector2 value2, out float result)
Definition Vector2.cs:114
static void Divide(ref Vector2 value1, ref Vector2 value2, out Vector2 result)
Definition Vector2.cs:651
static Vector2 Min(Vector2 value1, Vector2 value2)
Definition Vector2.cs:173
static Vector2 Barycentric(Vector2 value1, Vector2 value2, Vector2 value3, float amount1, float amount2)
Definition Vector2.cs:241
static Vector2 Normalize(Vector2 value)
Definition Vector2.cs:139
static Vector2 CatmullRom(Vector2 value1, Vector2 value2, Vector2 value3, Vector2 value4, float amount)
Definition Vector2.cs:273
static bool operator==(Vector2 value1, Vector2 value2)
Definition Vector2.cs:681
static Vector2 Subtract(Vector2 value1, Vector2 value2)
Definition Vector2.cs:601
static Vector2 Transform(Vector2 position, Matrix matrix)
Definition Vector2.cs:317
static void Add(ref Vector2 value1, ref Vector2 value2, out Vector2 result)
Definition Vector2.cs:595
static void SmoothStep(ref Vector2 value1, ref Vector2 value2, float amount, out Vector2 result)
Definition Vector2.cs:265
static Vector2 TransformNormal(Vector2 normal, Matrix matrix)
Definition Vector2.cs:335
static void TransformNormal(Vector2[] sourceArray, int sourceIndex, ref Matrix matrix, Vector2[] destinationArray, int destinationIndex, int length)
Definition Vector2.cs:465
static void Subtract(ref Vector2 value1, ref Vector2 value2, out Vector2 result)
Definition Vector2.cs:609
static void Dot(ref Vector2 value1, ref Vector2 value2, out float result)
Definition Vector2.cs:126
static bool operator!=(Vector2 value1, Vector2 value2)
Definition Vector2.cs:690
static void Transform(Vector2[] sourceArray, int sourceIndex, ref Matrix matrix, Vector2[] destinationArray, int destinationIndex, int length)
Definition Vector2.cs:411
static void Transform(Vector2[] sourceArray, int sourceIndex, ref Quaternion rotation, Vector2[] destinationArray, int destinationIndex, int length)
Definition Vector2.cs:531
static Vector2 Transform(Vector2 value, Quaternion rotation)
Definition Vector2.cs:353
static void Transform(ref Vector2 value, ref Quaternion rotation, out Vector2 result)
Definition Vector2.cs:371
static Vector2 SmoothStep(Vector2 value1, Vector2 value2, float amount)
Definition Vector2.cs:255
static Vector2 Add(Vector2 value1, Vector2 value2)
Definition Vector2.cs:587
static void Clamp(ref Vector2 value1, ref Vector2 min, ref Vector2 max, out Vector2 result)
Definition Vector2.cs:215
static Vector2 Divide(Vector2 value1, Vector2 value2)
Definition Vector2.cs:643
static void TransformNormal(Vector2[] sourceArray, ref Matrix matrix, Vector2[] destinationArray)
Definition Vector2.cs:441
static void Barycentric(ref Vector2 value1, ref Vector2 value2, ref Vector2 value3, float amount1, float amount2, out Vector2 result)
Definition Vector2.cs:249
static Vector2 operator-(Vector2 value)
Definition Vector2.cs:673
static void Max(ref Vector2 value1, ref Vector2 value2, out Vector2 result)
Definition Vector2.cs:195
override string ToString()
Definition Vector2.cs:46
static void Negate(ref Vector2 value, out Vector2 result)
Definition Vector2.cs:581
static void Lerp(ref Vector2 value1, ref Vector2 value2, float amount, out Vector2 result)
Definition Vector2.cs:235
static void Distance(ref Vector2 value1, ref Vector2 value2, out float result)
Definition Vector2.cs:99
static void Min(ref Vector2 value1, ref Vector2 value2, out Vector2 result)
Definition Vector2.cs:181
static Vector2 operator+(Vector2 value1, Vector2 value2)
Definition Vector2.cs:699
static Vector2 Max(Vector2 value1, Vector2 value2)
Definition Vector2.cs:187
static void Reflect(ref Vector2 vector, ref Vector2 normal, out Vector2 result)
Definition Vector2.cs:166
static void Hermite(ref Vector2 value1, ref Vector2 tangent1, ref Vector2 value2, ref Vector2 tangent2, float amount, out Vector2 result)
Definition Vector2.cs:305
static void Transform(Vector2[] sourceArray, ref Quaternion rotation, Vector2[] destinationArray)
Definition Vector2.cs:495
static Vector2 operator/(Vector2 value1, Vector2 value2)
Definition Vector2.cs:739
static float DistanceSquared(Vector2 value1, Vector2 value2)
Definition Vector2.cs:107
static float Distance(Vector2 value1, Vector2 value2)
Definition Vector2.cs:91
static void Divide(ref Vector2 value1, float divider, out Vector2 result)
Definition Vector2.cs:666
static Vector2 Hermite(Vector2 value1, Vector2 tangent1, Vector2 value2, Vector2 tangent2, float amount)
Definition Vector2.cs:291
static void Transform(ref Vector2 position, ref Matrix matrix, out Vector2 result)
Definition Vector2.cs:327
Vector2(float x, float y)
Definition Vector2.cs:35
static void Normalize(ref Vector2 value, out Vector2 result)
Definition Vector2.cs:149
static Vector2 Lerp(Vector2 value1, Vector2 value2, float amount)
Definition Vector2.cs:227
static void Transform(Vector2[] sourceArray, ref Matrix matrix, Vector2[] destinationArray)
Definition Vector2.cs:387
static Vector2 Multiply(Vector2 value1, Vector2 value2)
Definition Vector2.cs:615