Coordinates of curves with turtle module in python

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • abhishek07
    New Member
    • Feb 2010
    • 3

    Coordinates of curves with turtle module in python

    How can i generate coordinates of curves using turtle module in python? I am a beginner in python.
  • vintello
    New Member
    • Feb 2010
    • 5

    #2
    you can see "The 50+ demo applications of the turtle module of Python are intended as examples for using Python and turtlegraphics in an educational setting." on this page - http://code.google.com/p/python-turtle-demo/. It`s interesting :)

    Comment

    • bvdet
      Recognized Expert Specialist
      • Oct 2006
      • 2851

      #3
      To generate the coordinates of a curve, you need an equation. Then you substitute values in the equation. Here's an example:
      Code:
      from time import sleep
      from turtle import *
      
      def parabolaY(x, a=0.250, b=-10, c=0):
          return a*x**2 + b*x + c
      
      pen = Pen()
      pen.tracer(True)
      pen.color('red')
      pen.width(3)
      pen.goto(0,0)
      pen.down()
      for x in range(0,51):
          pen.goto(x, parabolaY(x))
      pen.up()
      pen.goto(-100,-100)
      pen.color('green')
      pen.write("DONE!")
      sleep(2)
      pen._destroy()

      Comment

      Working...