我正在將數學課本中的任務轉移到處理中。其中一個問題需要使用拋物線。我決定把它寫成貝塞爾曲線,寫了代碼,但有些東西不起作用。誰能向我解釋我在這里做錯了什么?
代碼:
def setup():
background(255,255,255)
size(800,800)
rectMode(CENTER)
line(400,0,400,800)
line(0,400,800,400)
#B 0 to know the start and the end points
a=1
x=3
b=0
c=10
translate(width/2, height/2)
noFill()
beginShape()
#Parabola formula
y=-(a*x*x b*x c)
#X of the point of the symetry
Sx=(-b)/(2*a)
#Y of the point of the symetry
Sy=-(a*Sx*Sx b*Sx c)
#Derivative
Ny=-(800 b)
#Y of the starting point
By=-(a*400*400-b*400 c)
#Y of the end point
Ey=-(a*400*400 b*400 c)
#Y3 Y4
Ty=Ny*(x 400)-By
bezier(-400,By,Sx,Ty,400,Ey,Sx,Ty)
endShape()
noFill()
beginShape()
for i in range (-400,400):
x=i
y=-i
vertex(x,y)
endShape()
(它必須是 800x800 坐標平面、拋物線和直線。)
uj5u.com熱心網友回復:

轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/451715.html
上一篇:如何從給定串列中回傳一個數字串列,該串列將目標數字設為0?
下一篇:將C 中的數字除以3long's
