-
Notifications
You must be signed in to change notification settings - Fork 0
/
calculations.py
38 lines (36 loc) · 1.11 KB
/
calculations.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
from math import sqrt
def angleMath(movingX,movingY,targetX,targetY,movingSpeed):
"""
"m" like in y=mx+b
i wont explain the math because it is complicated but its calculating the angle it
needs to move and using pitagoras formula to change the speed it needs to do it
so it will be balanced
a lot of random characters are there, its because most of them are temporary
if they are used a lot of times they will have a understandable name
"""
mX = targetX - movingX
mY = targetY - movingY
try:
m = mY / mX
except:
m = 0
x = 1
x = x**2
if m > 0:
y = m**2
z = y + x
fm = sqrt(z)
i = 100 * movingSpeed
b = i/fm
newm = m * b * 0.01 * -1
newx = x * b * 0.01 * -1
elif m < 0:
y = m**2
z = y + x
fm = sqrt(z)
i = 100 * movingSpeed
b = i/fm
newm = m * b * 0.01 * -1
newx = x * b * 0.01 * -1
return [newx,newm]
#def