-
Notifications
You must be signed in to change notification settings - Fork 0
/
vec2.py
46 lines (34 loc) · 917 Bytes
/
vec2.py
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
class Vec2:
def __init__(self,x,y):
self.x = x
self.y = y
def __iadd__(self,vector):
self.x += vector.x
self.y += vector.y
return self
def __add__(self,vector):
return Vec2(self.x+vector.x, self.y+vector.y)
def __isub__(self,vector):
self.x -= vector.x
self.y -= vector.y
return self
def __sub__(self,vector):
return Vec2(self.x-vector.x, self.y-vector.y)
def __imul__(self,vector):
self.x *= vector.x
self.y *= vector.y
return self
def __mul__(self,vector):
return Vec2(self.x*vector.x, self.y*vector.y)
def __idiv__(self,vector):
self.x /= vector.x
self.y /= vector.y
return self
def __div__(self,vector):
return Vec2(self.x/vector.x, self.y/vector.y)
def __lt__(self,vector):
return self.x < vector.x and self.y < vector.y
def __gt__(self,vector):
return self.x > vector.x and self.y > vector.y
def vec2_copy(vector):
return Vec2(vector.x, vector.y)