volcano.py

Created by numworks-en

Created on November 02, 2022

894 Bytes


from matplotlib.pyplot import *
import math

Pi = math.pi
Xas = 0
Yas = -7000

RNG = 20
BND = 3.9
RST = 1/2-1/BND
XX = 9000 * 4250
X = math.sqrt(XX)

for ii in range(RNG+1):
    i = RNG-ii
    alpha = (1/(BND*RNG) * (i-4) + RST) * Pi
    ta = math.tan(alpha)
    a = -(1 + ta**2)/9000
    b = ta
    c = 2000
    disc = b*b - 4*a*c
    worteldisc = math.sqrt(disc)
    X0 = (-b+worteldisc)/(2*a)
    X1 = (-b-worteldisc)/(2*a)
    PN = min(8,max(round((X1-X0)/1000),5))
    xm = [-X1 + i*X1/(PN-1.) for i in range(PN)]
    fm = [a*xi**2 - b*xi + c for xi in xm]
    col = [255*i/RNG, 255*(0.5-i/(2*RNG)), 255*(1-i/RNG)]
    plot(xm, fm,col)
    xp = [X1*i/(PN-1) for i in range(PN)]
    fp = [a*xi**2 + b*xi + c for xi in xp]
    plot(xp,fp,col)

PN = round(X/300)
x = [-X + i*2*X/(PN-1) for i in range(PN)]
f = [-xi**2/9000 + 4250 for xi in x]
plot(x,f,[0,255,0])
grid()
show()