Turtle Conic Curve Series - Parabola
Environmental preparation
Running platform. Windows 7 Signature Edition
python Version.python 3.6.4
IDE: Python comes with IDLE
1、Drawing principle
If the equation of the parabola is: , and the point P is on the parabola, then the equation of the tangent to the parabola through the point P is.
2. Drawing a parabola
importturtleast
t.pencolor("red")
t.speed(1)
a=1
forxinrange(30):
a+=0.2
t.left(2)
t.forward(a)
t.penup()# no drawing when moving
t.goto(0,0)# return to the origin
t.pendown()# by default also draws the graph
t.left(120)# because the previous has been cumulatively rotated by 60 degrees
b=1
forxinrange(30):
b+=0.2
t.right(2)
t.forward(b)
t.mainloop()
Results of the run.
——The End ——