-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVector2.cs
More file actions
57 lines (51 loc) · 1003 Bytes
/
Vector2.cs
File metadata and controls
57 lines (51 loc) · 1003 Bytes
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
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Hotwire
{
public class Vector2
{
public double x;
public double y;
public Vector2()
{
x = 0;
y = 0;
}
public Vector2(double x, double y)
{
this.x = x;
this.y = y;
}
public double Length
{
get
{
return Math.Sqrt(x * x + y * y);
}
}
public static Vector2 operator *(Vector2 vec, double scale)
{
return new Vector2(vec.x * scale, vec.y * scale);
}
public static Vector2 operator +(Vector2 a, Vector2 b)
{
return new Vector2(a.x + b.x, a.y + b.y);
}
public static Vector2 operator -(Vector2 a, Vector2 b)
{
return new Vector2(a.x - b.x, a.y - b.y);
}
public static implicit operator PointF(Vector2 vec)
{
return new PointF((float)vec.x, (float)vec.y);
}
public static implicit operator Point(Vector2 vec)
{
return new Point((int)vec.x, (int)vec.y);
}
}
}