# MomTetrahedron.frink

use geometry.frink

// Return a polygon object representing the specified equilateral triangle.
// THINK ABOUT:  Would this be better as a GeneralPath of 4 disconnected
// polygons?
makeEquilateralTriangle[g is graphics, cx, cy, sideLength, rotation, label1="", label2="", label3="", center=""] :=
{
p = new polygon
halfL = 1/2 sideLength
h = halfL sqrt[3]
halfH = 1/2 h
rh = 2/3 h
thirdh = 1/3 h

x1 = cx
y1 = cy - rh
[x2, y2] = rotateAroundPoint[x1,y1,cx,cy,rotation]

x1 = cx - halfL
y1 = cy + thirdh
[x2, y2] = rotateAroundPoint[x1,y1,cx,cy,rotation]

x1 = cx + halfL
[x2, y2] = rotateAroundPoint[x1,y1,cx,cy,rotation]

x1 = cx
y1 = .95 thirdh + cy

g.text[center, cx, cy, rotation]
//g.fillEllipseCenter[cx, cy, .01, .01]

[x2, y2] = rotateAroundPoint[x1,y1,cx,cy,rotation+0 degrees]
g.text[label1, x2, y2, "center", "bottom", rotation + 0 degrees]

[x2, y2] = rotateAroundPoint[x1,y1,cx,cy,rotation+120 degrees]
g.text[label2, x2, y2, "center", "bottom", rotation + 120 degrees]

[x2, y2] = rotateAroundPoint[x1,y1,cx,cy,rotation-120 degrees]
g.text[label3, x2, y2, "center", "bottom", rotation - 120 degrees]
}

// Draw the specified tetrahedron into the graphics object.
makeTetrahedron[g is graphics, cx, cy, sideLength] :=
{
hl = sideLength / 2
ho = hl sqrt[3]
makeEquilateralTriangle[g, cx,           cy, sideLength, 0 deg, "Oratio - Prayer", "Meditatio - meditate", "Contemplatio - Contemplate", "Lectio Divinio"]
makeEquilateralTriangle[g, cx,      cy + 2/3 ho, sideLength, 180 deg, "God the Father", "God the Son", "God the Holy Spirit"]
makeEquilateralTriangle[g, cx + hl, cy + ho, sideLength, 0 deg, "Tropological - Love", "Allegorical - Faith", "Anagogical - Hope"]
makeEquilateralTriangle[g, cx - hl, cy + ho, sideLength, 0 deg, "Inform", "Form - Consciences", "Transform (in Christ)", "Conformity"]
}

g = new graphics
g.font["SansSerif", "bold", .05]
makeTetrahedron[g, 0, 0, 1]
g.show[]

This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen was born 18492 days, 22 hours, 42 minutes ago.