Equilateral Triangles

Kay C Lan lan.kc.macmail at gmail.com
Thu Jun 18 03:16:28 EDT 2015


As it happens I've just been doing a lot of trig plotting in LC recently.

The basic answer to this problem is that the sides of the square need to be
115% the sides of your triangle, with the base of your triangle horizontal
and parallel to the base of your square and the pinnacle of your triangle
touching the top of your square at a point which bisects the top line of
the square in half. It is the only point of the triangle which touches the
square. The loc of your square will logically be half that, therefore 57.5%
of the length of the side of the triangle.

So assuming you want a equilateral triangle with sides 200. Pick your
pinnacle. Draw a line to the right 60° below the horizon for 200. Draw a
line the left from the pinnacle, 60° below the horizon for 200. Join both
these points which should result in a 200 line parallel to the horizon. Now
from the pinnacle draw a line along the horizon which is 200 * 1.15 = 230,
115 to the left of the pinnacle, 115 to the right. From each end points
drop down 230. Then join these end points which again should be a 230 line
parallel to the horizon and your triangle base.

To draw the triangle inside a square in LC is relatively easy. The only
number you need to remember is 0.87 (which is Cos 30° in degrees not
radians; in LC use cos(30 * pi /180) to convert radian into degrees), the
rest you can calculate from the length of you triangle side. Assuming 200;

0.87 x 200 = 173 = the height of your triangle
1.15 x 200 = 230 = the sides of your square (which just happens to be 200 /
Cos 30)
0.5 x 200 = 100 = half the triangle side
0.5 x 230 = 115 = half the side of the square

First draw your square, in this case a 230 x 230 pixel square.
Assuming the top left is at 1,1, the midpoint along the top is at 116,1
Now draw a line (right side of triangle) from 116,1 to a point 100 further
right and 173 below, so 216,174
Draw the left side of the triangle from 116,1 to a point 100 to the left
and 173 below, so 16,174
Join these two points as your triangle base. (Note 16 to 216 = 200,
therefore your triangle base is correct)
The loc of your square. 116,116 is also the centre of your triangle.

HTH



More information about the use-livecode mailing list