-
Notifications
You must be signed in to change notification settings - Fork 0
/
vector.py
39 lines (35 loc) · 938 Bytes
/
vector.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
import math
class Vector:
def __init__(self) :
pass
def inputs(self,u,v):
self.u = u
self.v = v
vu = u.split(',')
self.vu =list(map(int,vu))
vv = v.split(',')
self.vv = list(map(int,vv))
def print(self):
vu = self.vu
vv = self.vv
out = '<{},{}> & <{},{}> '.format(vu[0],vu[1],vv[0],vv[1])
print(out)
def Magnitude(self,u):
vu = u.split(',')
vu =list(map(int,vu))
wh = (vu[0]**2)+(vu[1]**2)
mag = math.sqrt(wh)
return mag
def DotProduct(self):
vu = self.vu
vv = self.vv
ians = (vu[0]*vv[0])+(vu[1]*vv[1])
return ians
def Angle(self):
pro = self.DotProduct( )
um = self.Magnitude(self.u)
vm = self.Magnitude(self.v)
vum = um*vm
tar = pro/vum
ans = math.acos(tar)
return math.degrees(ans)