Python and Turtle Difficulty Level 5,loop,math,python Computing Sine and Cosine with Python Turtle

Computing Sine and Cosine with Python Turtle

Sine function of an angle θ is defined by the ratio of the length of the side of the triangle opposite to the angle and the length of the hypotenuse in a right triangle. Cosine function of an angle θ is defined by the ratio of the length of the side of the triangle adjacent to the angle and the length of the hypotenuse in a right triangle.

You can compute the sine and cosine value of an angle θ by starting from point (0,0) and setheading to the angle θ and forward a unit. The x coordinate of the Turtle is the cosine value of θ and y coordinate of the Turtle is the sine value of θ. After knowing how to computing it, use angle as the x coordinate and sine and cosine values of the angle as y coordinate and draw a series of dots from -360 degree to 360. Because sine and cosine values are very small (<=1), you can multiply the the values by 100 to see a curve looks below. (Red is Sine, Blue is Cosine)

Computing Sine and Cosine with Python Turtle
Tags: ,

Related Post