Debian Codegraph @

planetary_system_stacker/Test_programs/parabola.py

raw symbols SCIP
1 from math import sqrt
2
3 x0 = 0.
4 x1 = 50.
5 x2 = 200.
6
7 y0 = 0.
8 y1 = 13.
9 y2 = 255.
10
11 b = (y1 - y0) / (x1 - x0)
12 c = (y2 - y1 - b * (x2 - x1)) / (x1 ** 2 + x2 ** 2 - 2 * x1 * x2)
13 f = c * x1 ** 2 - b * x1 + y1
14 e = b - 2. * c * x1
15 g = -e / (2. * c)
16 h = g ** 2 - f / c
17
18 print("b = " + str(b))
19 print("c = " + str(c))
20 print("e = " + str(e))
21 print("f = " + str(f))
22 print("g = " + str(g))
23 print("h = " + str(h))
24
25 x = 200
26
27 print ("\nx: " + str(x))
28 if x < x1:
29 y = y0 + b * (x - x0)
30 else:
31 y = round(c * x ** 2 + e * x + f, 1)
32 print("y: " + str(y))
33
34 x = round(g + sqrt(h + y / c))
35 print ("x: " + str(x))