-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.py
69 lines (62 loc) · 1.9 KB
/
functions.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
import TRON
def transferCoordinates(x1, y1, x2):
firstcamx = (x2 - 640 / 2) / 40
secondcamx = (x1 - 640 / 2) / 40
firstcamz = (480 / 2 - y1) / 40
kinda23 = 30.8724
if firstcamx != 0:
a = kinda23 / (firstcamx)
if secondcamx != 0:
b = kinda23 / (secondcamx)
if firstcamz != 0:
c = kinda23 / (firstcamz)
if firstcamx != 0 and secondcamx != 0 and firstcamz != 0:
x_fill = (a + b) / (a - b)
y_fill = (2 * a * b) / (a - b)
z_fill = y_fill / c
if firstcamz == 0 and firstcamx != 0 and secondcamx != 0:
x_fill = (a + b) / (a - b)
y_fill = (2 * a * b) / (a - b)
z_fill = 0
if firstcamx == 0 and firstcamz != 0:
x_fill = 1
y_fill = 2 * b
z_fill = y_fill / c
if secondcamx == 0 and firstcamz != 0:
x_fill = -1
y_fill = -2 * a
z_fill = y_fill / c
if firstcamx == 0 and firstcamz == 0:
x_fill = 1
y_fill = 2 * b
z_fill = 0
if secondcamx == 0 and firstcamz == 0:
x_fill = 1
y_fill = -2 * a
z_fill = 0
# normalize coordinates
x_fill *= -2
z_fill *= -2
if y_fill > 0 and y_fill < 30:
return [x_fill, y_fill, z_fill]
def getArrayAverage(array):
if len(array) == 0:
return 0
sum = 0
for i in array:
sum += i
return sum / len(array)
def drawBase():
lines_len = 20
TRON.setColorRGB(0, 0, 1)
TRON.drawLine(0, 0, 0, lines_len, 0, 0)
for i in range(lines_len):
TRON.drawSphere(i, 0, 0, 0.05, 10)
TRON.setColorRGB(0, 1, 0)
TRON.drawLine(0, 0, 0, 0, -lines_len, 0)
for i in range(lines_len):
TRON.drawSphere(0, -i, 0, 0.05, 10)
TRON.setColorRGB(1, 0, 0)
TRON.drawLine(0, 0, 0, 0, 0, lines_len)
for i in range(lines_len):
TRON.drawSphere(0, 0, i, 0.05, 10)