|
发表于 2021-5-12 13:48:58
|
显示全部楼层
#cas
def pyhat():
t0 = ticks # Save the current clock count for timing program
# Clear screen
rect_p(0,0,319,239,rgb(0,0,0))
# Start program proper
p=160; q=120
xp=144; xr=1.5*3.1415927
yp=56; yr=1; zp=64
xf=xr/xp; yf=yp/yr; zf=xr/zp
for zi in range(-q,q+1):
if zi>=-zp and zi<=zp:
zt=zi*xp/zp; zz=zi
xl=int(.5+sqrt(xp*xp-zt*zt))
# Draw one cross-section of figure
for xi in range(-xl,xl+1):
xt=sqrt(xi*xi+zt*zt)*xf; xx=xi
yy=(sin(xt)+.4*sin(3*xt))*yf
x1=xx+zz+p
y1=yy-zz+q
pixon_p(x1,230-y1,rgb(0,255,0))
if y1!=0:
Line_p(x1,230-y1+1,x1,230) # Erase points below current point
t = ticks-t0
# Wait for key and print elapsed time
wait
print(approx(t/1000)+" seconds")
#end |
|