Sunday 6 May 2018

Sepow


Sepow means "Executioner's knife". It is the symbol of A symbol of justice.

We will use the 5 pixel grid to trace out this image. The image of this is shown below:


The plan to draw this shape is given below:
  1. Lift up the pen
  2. Set the pensize to 30 pixels
  3. Move the pen to the location of the leftmost part of the triangle
  4. Find the distance and the angle between the leftmost part and the topmost part
  5. Draw the triangle
  6. Draw the circle
Using Turtle Graphics

We will use the template.py file and rename it to sepow.py.

Steps 1 and 2  are simple, we only need to lift up the pen. The code to do this is shown below:

turtle.penup()
turtle.pensize(30)

The leftmost tip of the pen is at (-105, -20) to find the optimal position of the pen, we must add 15 pixels to it. This gives us: (-90, -5).

Compensating for the position of the pen, the coordinate of the topmost position is (0, 175).

The function to find the angle between the two points is given below:

def angleBetweenPoints(x1, y1, x2, y2):
    myradians = math.atan2(y2 - y1, x2 - x1)
    angle = math.degrees(myradians)
    return angle
The function to find the distance between the two point is given below:

def coordinateDistance(x1, y1, x2, y2):
    dx = x1 - x2
    dy = y1 - y2
    D = math.sqrt((dx * dx) + (dy * dy))
    return D
To use the above functions, we use the code shown below:

angle = angleBetweenPoints(-90, -5, 0, 175)
length = coordinateDistance(-90, -5, 0, 175)

To draw the triangle, we use the code shown below:

turtle.setposition(-90, -5)
turtle.pendown()
turtle.setheading(angle)
turtle.forward(length)
turtle.setheading(360 - angle)
turtle.forward(length)
turtle.setheading(180)
length = coordinateDistance(-90, -5, 90, -5)
turtle.forward(length)

The generated image is shown below:


Drawing the circle is quite easy. We move the turtle to the position (85, -90) and draw a circle of radius 85 pixels.

The code to do this is shown below:

turtle.penup()
turtle.setposition(85, -90)
turtle.pendown()
turtle.setheading(90)
turtle.circle(85)

The generated image is shown below:


Conclusion

At the end of this section, we have successfully drawn the Sepow symbol.

This post is part of the series: Drawing Adinkra Symbols using Python. The goal is to draw 40 Adinkra symbols using the Python programming language.

No comments:

Post a Comment