-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVector.cs
More file actions
42 lines (37 loc) · 739 Bytes
/
Copy pathVector.cs
File metadata and controls
42 lines (37 loc) · 739 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
namespace hashes
{
public class Vector
{
public double X { get; private set; }
public double Y { get; private set; }
public Vector(double x, double y)
{
X = x;
Y = y;
}
public Vector Add(Vector other)
{
X += other.X;
Y += other.Y;
return this;
}
protected bool Equals(Vector other)
{
return X.Equals(other.X) && Y.Equals(other.Y);
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((Vector) obj);
}
public override int GetHashCode()
{
unchecked
{
return (X.GetHashCode()*397) ^ Y.GetHashCode();
}
}
}
}