-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathVec2.cs
37 lines (28 loc) · 984 Bytes
/
Vec2.cs
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
using System;
using System.Drawing;
namespace Astroshooter
{
public class Vec2
{
public double X { get; set; }
public double Y { get; set; }
public Vec2()
{
}
public Vec2(double x, double y)
{
X = x;
Y = y;
}
static public PointF TransformToPointF(Vec2 vector) => new PointF((float)vector.X, (float)vector.Y);
static public Point TransformToPoint(Vec2 vector) => new Point((int)vector.X, (int)vector.Y);
static public double GetDistanceBetween(Vec2 left, Vec2 right)
{
var dx = left.X - right.X;
var dy = left.Y - right.Y;
return Math.Sqrt(dx*dx + dy*dy);
}
public static Vec2 operator + (Vec2 left, Vec2 right) => new Vec2(left.X + right.X, left.Y + right.Y);
public static Vec2 operator *(Vec2 left, double multiplier) => new Vec2(left.X * multiplier, left.Y * multiplier);
}
}