-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIPRO 8direction.py
90 lines (79 loc) · 2.51 KB
/
IPRO 8direction.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Oct 6 21:47:57 2018
@author: cara4lyfe
"""
from math import *
import sympy
# In[10]:
#input
xAxis = list(range(-128,129))
yAxis = list(range(-128,129))
# In[ ]:
#constants
maxSpeed = 100
#dic to store data
dic = {}
noPositive = 0
# In[84]:
tan(radians(45.5))
# In[84]:
#Advanced
noPositive = 0
n = 0
i = 0
for Fx in xAxis:
for Fy in yAxis:
#ratio of power:
r = sqrt((Fx**2+Fy**2)/128**2)
if Fx == 0:
tang = 9999999 #when x = 0 tan is infi
else:
tang = abs(Fy/Fx)
if (Fx**2+Fy**2<=128**2):
if tang >= tan(radians(67.5)) and Fy >= 0:
#region 1
dic[(Fx,Fy)]= (maxSpeed,maxSpeed,0)
elif tang < tan(radians(67.5)) and tang >= tan(radians(22.5)) and Fy >= 0 and Fx >= 0:
#region 2
dic[(Fx,Fy)]= (maxSpeed/sqrt(2),maxSpeed/sqrt(2),0)
elif tang < tan(radians(22.5)) and Fx >= 0:
#region 3
dic[(Fx,Fy)]= (0,2*maxSpeed/sqrt(3),maxSpeed/sqrt(3))
elif tang < tan(radians(67.5)) and tang >= tan(radians(22.5)) and Fy < 0 and Fx >= 0:
#region 4
dic[(Fx,Fy)]= (0,2*maxSpeed/sqrt(6),(maxSpeed/sqrt(2)+maxSpeed/sqrt(6)))
elif tang >= tan(radians(67.5)) and Fy < 0:
#region 5
dic[(Fx,Fy)]= (0,0,maxSpeed)
elif tang < tan(radians(67.5)) and tang >= tan(radians(22.5)) and Fy < 0 and Fx < 0:
#region 6
dic[(Fx,Fy)]= (2*maxSpeed/sqrt(6),0,(maxSpeed/sqrt(2)+maxSpeed/sqrt(6)))
elif tang < tan(radians(22.5)) and Fx < 0:
#region 7
dic[(Fx,Fy)]= (2*maxSpeed/sqrt(3),0,maxSpeed/sqrt(3))
elif tang < tan(radians(67.5)) and tang >= tan(radians(22.5)) and Fy >= 0 and Fx < 0:
#region 8
dic[(Fx,Fy)]= (maxSpeed/sqrt(2),maxSpeed/sqrt(2),0)
else:
print(Fx,Fy)
i = i+1
print(n)
n = n+1
print("misshit: ", i)
print(n)
print("Done")
# In[84]:
f = open('IPRO8directiondata.txt','w')
for key in dic:
f.write("%i, %i\n" % (key[0], key[1]))
f.write("%f, %f, %f\n" % (dic[key][0], dic[key][1], dic[key][2]))
f.write('EOF')
f.close()
# In[84]:
f = open('IPRO8directiondataOneLineRounded.txt','w')
for key in dic:
f.write("%i,%i,%i,%i,%i\n" % (key[0], key[1],dic[key][0], dic[key][1], dic[key][2]))
f.write('EOF')
f.close()