I designed A, J, Q, and Z.

I accidentally missed the part where I was to submit after each
letter. Sorry! I'll answer the prompt for all 4 letters.

A:
I realized while it was easy to draw any line segment by hand, it
was not immediately obvious how I might draw a line of any slope,
as opposed to a slope of 0, -1, 1, or undefined, using the tools
I already had. I happened to know it involved the inverse tangent,
so it was just a matter of googling whether that was already a
function in Python. I was excited that I knew the mathematics
I needed to figure out the angle I would have to rotate, but did
wonder I how would've felt had I not know how to transfer to
the computer what I had first sketched on paper.

J:
Since I had done all straight lines with A, I wanted to use
the circle function in this letter. The documentation you provided
on it mentioned that the radius was the distance from the starting
position to the center of the circle that was left of the turtle.
I found, in both A and J, I had difficulty understanding whether
to turn right or left and by what angle from the perspective of
the turtle. I was actually a bit frustrated with this letter, and
I found myself at various times rotating my head, body, and
computer to figure it out. I falso figured out, through trial and
error, that I could specify a negative radius if I wanted the
center to be to the turtle's right. I would change a parameter,
run the program, and decide if it needed further changing or if a
different parameter needed to be changed.

Q:
For Q, I opted to use straight lines, but I decided I wanted a
vertical bar through the open space of the Q. I was inspired by
the set of rational numbers, but I forgot it was through the left
side instead of the right, although I ended up liking the way it
came out. I started with the simpler problem of making a Q without
the bar first. It was only after I figured out how to make a
regular Q when I figured out where and when to the put up or down
so I could draw a vertical bar through it without having
overlapping segments. One thing I noticed as I was writing was
that the way I made the sort of elliptical part of the Q could
be rewritten as a for loop iterating 4 times, which worked for the
case of the normal Q. I was originally excited about getting the
opportunity to use a for loop, but it didn't make sense to loop 4
times when I needed to move the pen up and down on the right side
only as I drew the vertical bar. It was briefly annoying that my
idea to use a loop for the entire Q besides the tail didn't work,
but it was a fairly quick adjustment, since I could still have it
loop twice on the left side that remained the same in the original
version and what I ended up with.

Z:
I was really proud of how I did my Z! I chose a symmetrical design
for it, so I was able to write half the letter out in a for loop
that ran twice to do it. Being intentional about the way I
designed the Z paid off in the relative ease in which I was able
to write the code for it.
This commit is contained in:
Cory Dean Chung
2023-07-27 15:18:05 -04:00
parent c4257ccd99
commit 5d1a98a462
2 changed files with 253 additions and 97 deletions

View File

@@ -11,9 +11,46 @@
from turtle import *
from math import sqrt
from math import atan
from math import degrees
def draw_letter_a(unit):
pass
penup()
forward(unit)
pendown()
forward(1.5 * unit)
left(degrees(atan(2)))
forward(sqrt(5) * 1.5 * unit)
right(degrees(atan(2)))
forward(unit)
right(90)
forward(3 * unit)
left(90)
forward(2 * unit)
left(90)
forward(8 * unit)
left(90)
forward(2 * unit)
left(degrees(atan(2)))
forward(sqrt(5) * 4 * unit)
left(180 - degrees(atan(2)))
penup()
forward(3 * unit)
left(90)
forward(4 * unit)
pendown()
right(90)
forward(1 * unit)
left(90)
forward(2 * unit)
left(90 + degrees(atan(2)))
forward(sqrt(5) * unit)
penup()
forward(sqrt(5) * 2 * unit)
right(degrees(atan(2)))
forward(2 * unit)
right(180)
pendown()
def draw_letter_b(unit):
pass
@@ -40,7 +77,37 @@ def draw_letter_i(unit):
pass
def draw_letter_j(unit):
pass
print(heading())
print(pos())
left(90)
penup()
forward(8 * unit)
right(90)
forward(unit)
pendown()
forward(6 * unit)
right(90)
forward(6 * unit)
circle(-2 * unit, 90)
forward(2 * unit)
circle(-2 * unit, 90)
forward(unit)
right(90)
forward(2 * unit)
right(90)
forward(unit)
circle(unit, 180)
forward(4 * unit)
left(90)
forward(4 * unit)
right(90)
forward(2 * unit)
penup()
left(90)
forward(unit)
left(90)
forward(8 * unit)
left(90)
def draw_letter_k(unit):
pass
@@ -61,7 +128,62 @@ def draw_letter_p(unit):
pass
def draw_letter_q(unit):
pass
penup()
forward(3 * unit)
pendown()
forward(2 * unit)
left(45)
forward(sqrt(2) * unit / 2)
penup()
forward(sqrt(2) * unit / 2)
pendown()
forward(2 * sqrt(2) * unit)
left(45)
for i in range(3):
forward(2 * unit)
left(45)
forward(3 * sqrt(2) * unit)
left(45)
penup()
forward(unit)
left(90)
forward(unit)
right(45)
for i in range(2):
pendown()
forward(sqrt(2) * unit)
penup()
forward(sqrt(2) * unit)
pendown()
forward(sqrt(2) * unit)
left(90)
for i in range(2):
forward(3 * sqrt(2) * unit)
left(90)
forward(sqrt(2) * unit)
left(45)
forward(4 * unit)
right(135)
penup()
forward(sqrt(2) * unit)
right(45)
pendown()
forward(2 * unit)
penup()
forward(2 * unit)
pendown()
left(45)
forward(sqrt(2) * unit)
right(135)
forward(unit)
right(45)
forward(sqrt(2) * unit / 2)
penup()
left(90)
forward(sqrt(2) * unit / 2)
right(45)
forward(5 * unit)
right(180)
def draw_letter_r(unit):
pass
@@ -88,4 +210,38 @@ def draw_letter_y(unit):
pass
def draw_letter_z(unit):
pass
penup()
forward(3 * unit)
left(90)
forward(4 * unit)
right(degrees(atan(2 / 3)))
pendown()
for i in range(2):
forward(sqrt(13) * unit)
left(90 + degrees(atan(2 / 3)))
forward(4 * unit)
right(90)
forward(unit)
right(90)
forward(6 * unit)
right(90)
forward(unit)
right(degrees(atan(2 / 3)))
forward(sqrt(13) * unit)
penup()
right(90 - degrees(atan(2 / 3)))
forward(unit / 2.0)
left(90 - degrees(atan(2/3)))
pendown()
for i in range(2):
forward(sqrt(13) * unit)
right(90 - degrees(atan(2 / 3)))
forward(unit)
right(90 + degrees(atan(2 / 3)))
forward(sqrt(13) * unit)
left(90 + degrees(atan(2 / 3)))
penup()
forward(3.5 * unit)
left(90)
forward(4 * unit)
left(90)