At My Fingertips

Rapid Playground

Documentation

Rhombus

Implement the rhombus function to recreate the following graphic.

rhombus

A rhombus is composed of two isosceles triangles placed one above the other.

The vertical isosceles triangle

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 PyTamaro iconrotate function requires a negative angle to rotate clock-wise.

  • result of triangle(160, 160, 40, black)

    triangle not rotated

  • with horizontal and vertical axis to help find the angle of rotation

    isosceles triangle rotation

  • wanted result

    triangle rotated

Loading...

The rhombus

Now you only have to combine two isosceles triangles one above the other to generate a rhombus. Implement the rhombus function using the pytamaro PyTamaro iconabove and PyTamaro iconrotate functions, together with the isosceles_triangle function that you just implemented.

Loading...

This activity has been created by LuCE Research Lab and is licensed under CC BY-SA 4.0.

Rhombus

Logo of PyTamaro

PyTamaro is a project created by the Lugano Computing Education Research Lab at the Software Institute of USI

Privacy PolicyPlatform Version d900fe4 (Fri, 26 Apr 2024 16:23:18 GMT)