Triangles

triangles_mini

Next pictures are related to the equilateral triangle: angles of the regular triangle (in SVG), extreme points of an equilateral triangle with rounded corners (in SVG) and the impossible object Reutersvärd triangle (in SVG).

Angles of regular polygons

We can draw an equilateral triangle repeating FORWARD and RIGHT commands:

REPEAT 3 [ FORWARD 100 RIGHT 120 ]

More automatization could create the series of regular polygons, also with angles and other annotation, see the gallery and attached LibreLogo source code of the Wikipedia illustration:
regpol_mini

Extreme points

Next triangle is the result of the SVG transition of a mathematical illustration (the original picture was in the Wikimedia Commons category Top 200 images that should use vector graphics by usage).
The program of the picture draws 1 inch width outline with rounded corners, and in a second turn, narrow arcs with the appropriate radius.

HIDETURTLE 
PICTURE “Extreme points.svg” [
    FILLCOLOR “SKYBLUE” PENCOLOR “SKYBLUE”
    PENSIZE 72 RIGHT 30
    FORWARD 100 RIGHT 120 FORWARD 100 FILL
    PENCOLOR “RED” PENSIZE 2
    REPEAT 3 [
        CIRCLE [70, 70, 9h, 1h, 3] 
        PENUP RIGHT 120 FORWARD 100 PENDOWN
    ]
]

svg_export_bug
Note: this illustration helped to find a rare SVG export problem, see the enlarged line end on the right picture and the LibreOffice bug report.

Reutersvärd optical illusion

One of the best optical illusions, created by the Swedish artist, Oscar Reutersvärd at the age of 18, in 1934. The next program draws the left picture. To get the optical illusion, open the SVG file in LibreOffice Draw, and place two shapes (bottom sides of the first cube) to foreground manually (for example, by Ctrl-Shift-+).
Reutersvard_mod

TO tile
LEFT 60
REPEAT 2 [
    FORWARD 40 RIGHT 120 FORWARD 40 RIGHT 60
] FILL RIGHT 60
END

TO cube
colors = [“GOLD”, “TEAL”, “TOMATO”]
REPEAT 3 [ 
    PENCOLOR colors[REPCOUNT-1]
    FILLCOLOR colors[REPCOUNT-1]
    tile
    RIGHT 120
]
END

PICTURE “Reutersvärd triangle.svg” [
HIDETURTLE PENSIZE 0.1 RIGHT 30
REPEAT 3 [
    REPEAT 3 [
        PENUP FORWARD 60 PENDOWN
        d = HEADING
        HEADING 30
        cube
        HEADING d
    ]
    RIGHT 120
]
]

Note: Using narrow outlines (instead of “invisible” PENCOLOR) limits the SVG rendering problems in low resolution.

Egy hozzászólás a(z) “Triangles” bejegyzéshez

  1. I barely try to resolve the little problem redrawing the last cube:


    TO tile
    LEFT 60
    REPEAT 2 [
    FORWARD 40 RIGHT 120 FORWARD 40 RIGHT 60
    ] FILL RIGHT 60
    END
    TO cube
    colors = [“GOLD”, “TEAL”, “TOMATO”]
    REPEAT 3 [
    PENCOLOR colors[REPCOUNT-1]
    FILLCOLOR colors[REPCOUNT-1]
    tile
    RIGHT 120
    ]
    END
    TO lastcube
    colors = [“TEAL”, “TOMATO”]
    right 120
    REPEAT 2 [
    PENCOLOR colors[REPCOUNT-1]
    FILLCOLOR colors[REPCOUNT-1]
    tile
    RIGHT 120
    ]
    END
    HOME
    HIDETURTLE PENSIZE 0.1 RIGHT 30
    REPEAT 3 [
    REPEAT 3 [
    PENUP FORWARD 60 PENDOWN
    d = HEADING
    HEADING 30
    cube
    HEADING d
    ]
    RIGHT 120
    ]
    PENUP FORWARD 60 PENDOWN
    lastcube

Leave a Reply

Your email address will not be published. Required fields are marked *