avatarJim McAulay🍁 I'm nobody. Are you a nobody too?

Summary

The website content provides an explanation on how to use Python's Turtle module to draw an equilateral triangle using both the forward and right commands as well as the circle command, illustrating the versatility of the circle command in drawing regular polygons and approximating circles.

Abstract

The article introduces the concept of drawing shapes with Python's Turtle module, focusing on creating an equilateral triangle. Initially, it demonstrates a straightforward approach using the forward and right functions to draw the triangle by specifying the side length and internal angles. Subsequently, the article explores an alternative method utilizing the circle command, which can also be employed to generate other regular polygons and circles by adjusting the parameters for side length, angle extent, and the number of steps. It highlights that a regular polygon with a large number of sides, such as a 19-sided enneadecagon, will appear indistinguishable from a circle when drawn using the Turtle module. The circle command approximates a circle by drawing an inscribed regular polygon, with the parameters determining the side length, whether a full circle or an arc is drawn, and the level of detail in the shape.

Opinions

  • The author suggests that the circle command in the Turtle module is a powerful tool for drawing not only circles but also regular polygons, including triangles.
  • It is implied that the Turtle module's ability to draw regular polygons that resemble circles when the number of sides is large is a testament to the module's capabilities in creating geometric shapes.
  • The article quotes Jim McAulay🍁, emphasizing a philosophical perspective on problem-solving and acceptance, which may be analogous to the adaptability of the Turtle module's circle command in addressing various drawing needs.

Using Python Turtle To Draw A Triangle With The Circle Command

An introduction to circles

screen capture personal computer

Here is one way of drawing an equilateral triangle with turtle.

import turtle as T
forward (174)
right (120)
forward (174)
right (120)
forward (174)

To draw a similar sized equilateral triangle with the circle command try the following module

import turtle as T
T.circle (100,360,3)

The circle command can be used to draw triangles, squares, circles or any regular polygon.

A regular polygon is equilateral and equiangular.

That is it is an enclosed figure in which all sides and angles are equal. As the number of sides increase it becomes increasingly difficult to distinguish between the polygon and a circle.

In fact anything larger than an enneadecagon (a 19 sided regular polygon) drawn with turtle will appear identical to a circle.

In the turtle module a circle is approximated by an inscribed regular polygon.

The first number is the length of the sides the second number determines if you are drawing a full circle or an arc. it is by default 360 degrees. The last number is the steps in drawing the circle.

T.circle (100)   will draw a circle with a hundred pixel radius.
T.circle (100,180,) will draw a semicircle.
T.circle (100,360,5) will draw a regular pentagon.
T.circle (100,360,20)  is identical to a regular circle.

Jim McAulay🍁 says: “If there is a remedy, then what is the use of frustration? If there is no remedy, then what is the use of frustration?” — Shantideva

50–50

18–18

Technology
Python
Python Turtle
Jim Mcaulay
Illumination
Recommended from ReadMedium