As I see it, the purpose of programming is to build machines out of bytes that are impossible or too expensive to build out of atoms. Computers are machines that can imitate any other machine. Programming is the act of making them do that.
Abusua Pa means “Good Family”. It is the symbol of the family unit. Typically in Akan culture, Abusua is the name in Akan culture for a group of people that share common maternal ancestry.
The Abusua line is considered to be passed through the mother’s blood. It is a taboo to marry someone from the same Abusua.
We will use the 5-pixel grid to trace out this image. The image of this is shown below:
Analysing the Symbol
The symbol is a composite symbol made up of a hollowed out square. The inner part of the square consists of four sections which are lined like a window pane.
The outer part of the square intersects with 4 semi-circles. The widths of all the component shapes are the same.
The Plan to Draw the Symbol
To draw this symbol, the first task is to increase the pensize to 40 pixels. Next we move the turtle to the position (-100, 100).
We find the distance between (-100, 100) to (100, -100) and use the drawSquare function to draw the outer square.
Next we move to the position (-100, 0) and draw the horizontal centre line. We then move to the position (0, -100) and draw the vertical centre line.
Once we have completed the outer square and its centre lines, we draw the external semi-circles.
Finally, we reduce the pensize to 5 and draw the inner sections of the symbol.
Algorithm to Draw the Symbol
The algorithm to draw the Abusua Pa symbol is shown below:
Lift up the pen
Set the pensize to 40 pixels
Set the position of the pen to the location (-100, 100)
Place the pen down
Find the length of the side of the outer square
Draw the outer square
Draw the inner centre lines
Draw the outer semi-circles
Reduce the pensize to 5
Draw the inner squares
Using Turtle Graphics
We will use the template.py file and rename it to abusuapa.py.
We then draw a square using the drawSquare function.
The generated image is shown below:
I realize that since we are using the drawSquare function, we no longer need the setposition code. We can comment it out.
To draw the center lines, we have to move the turtle to the left-hand side and move forward by the length of the side. Next, we move the turtle to the bottom, set its heading to 90 degrees and move up by the length of the side. The code to do this is shown below:
To draw the outer circle we will start with the top and move clockwise. To draw the upper circle, we need to move the turtle to the position (50, 120). Then we draw the semi-circle. The code to do this is shown below:
Completing this shape is easy. All we have to do is draw the lines that are within the squares. To do this we must reduce the pensize to 5 and set the orientation of the turtle appropriately to draw the lines.
In step 4 of the algorithm to draw Aban, we have to find the width of the shape. We will also need to find the length of the shape.
To find the width of the line, we need to find the distance between two parallel points it passes through and this are: (120, 0) and (40, 80).
To find the length of a side of the Aban symbol, we take the point (0, 80) as our starting point and get the coordinates of the centre point (80, 160) which is where a line drawing the symbol would stop and turn.
We have to introduce a function coordinateDistance to give us the distance between the two coordinates. The function definition is shown below:
def coordinateDistance(x1, y1, x2, y2):
dx = x1 – x2
dy = y1 – y2
D = math.sqrt((dx * dx) + (dy * dy))
To find the width and length, we use the expressions below:
To draw the shape completely, we need to call this function and alternate with the setheading angle that is representative of the quadrant the function will draw in. The code to do this is shown below: