At My Fingertips
Rapid Playground
Implement the rhombus
function to recreate the following graphic.
A rhombus is composed of two isosceles triangles placed one above the other.
Let's start by implementing the isosceles_triangle
function, that generates an isosceles triangle rotated vertically (straight).
An approach could be to call the triangle function with the same value for the two sides and the given angle between them, and then rotate it accordingly. The following sketches might help you with the reasoning on the rotation angle.
Note that the rotate function requires a negative angle to rotate clock-wise.
result of triangle(160, 160, 40, black)
with horizontal and vertical axis to help find the angle of rotation
wanted result
Now you only have to combine two isosceles triangles one above the other to generate a rhombus. Implement the rhombus
function using the pytamaro above and rotate functions, together with the isosceles_triangle
function that you just implemented.
This activity has been created by LuCE Research Lab and is licensed under CC BY-SA 4.0.
Rhombus
PyTamaro is a project created by the Lugano Computing Education Research Lab at the Software Institute of USI
Privacy Policy • Platform Version d900fe4 (Fri, 26 Apr 2024 16:23:18 GMT)