At My Fingertips
Rapid Playground
Have a look at these geometric figures:
A | B | C | D | E |
---|---|---|---|---|
They are all known as kite shapes. Here are some similarities:
Notice that they are rotated such that the symmetry line is vertical.
Kites A, B, and C are convex, kites D and E are concave.
def kite(...) -> Graphic:
We can see that the color differs,
so we want to have a parameter to specify the color
.
There are different approaches to unambiguously specify the shape. Here is one possible way:
symmetry_diagonal
bottom_sides
(because of the symmetry, the two bottom sides have the same length)bottom_angle
(the angle between the bottom sides)There would be other ways (e.g, to specify other angles, the other diagonal, the other side lengths),
but let's go with symmetry_diagonal
, bottom_side
, and bottom_angle
.
The following function signature reflects this choice:
def kite(symmetry_diagonal: float, bottom_side: float, bottom_angle: float, color: Color) -> Graphic:
How would you decompose a kite, given that you have functions to create a rectangle, triangle, ellipse, and circular_sector?
One way to achieve this is to decompose the kite into triangles. We could decompose it into:
Let's decompose it into two triangles along the symmetry diagonal:
Hint: Make sure that your function can produce all the examples (convex and concave kites) shown at the beginning.
Play with your kite
function, creating kites with different sizes and angles.
If you use 180 degrees for the bottom point, the bottom isosceles triangle collapses into a line, and only the top isosceles triangle remains.
Bottom angles greater than 180 degrees lead to concave kites. At a bottom angle of 360 degrees the kite degenerates into a line, similar to a bottom angle of 0 degrees.
Here is an overview of the effect of different bottom angles:
bottom_angle | shape |
---|---|
angle = 0 | degenerate kite (line) |
0 < angle < 180 | convex kite |
angle = 180 | degenerate kite (isosceles triangle) |
180 < angle < 360 | concave kite |
angle = 360 | degenerate kite (line) |
Save the kite
function in your toolbox.
It will come in handy when creating other graphics (such as a star).
This activity has been created by LuCE Research Lab and is licensed under CC BY-SA 4.0.
Kite
PyTamaro is a project created by the Lugano Computing Education Research Lab at the Software Institute of USI
Privacy Policy • Platform Version 1cd5229 (Tue, 05 Nov 2024 16:55:57 GMT)