MODULE Triangle; (* Procedures and predicates for triangles. *) IMPORT Math, R2, Geometry, PS, Angle; PROC Draw(a, b, c) IS IF PS.MoveTo(a); PS.LineTo(b); PS.LineTo(c); PS.Close() FI END; UI PointTool(Draw); (* Add the closed triangle on the vertices "a", "b", and "c" to the current path. *) FUNC p = OutCenter(a, b, c) IS (b, p) CONG (p, a) AND (a, p) CONG (p, c) END; UI PointTool(OutCenter); (* "p" is the center of the circle circumscribing the triangle "abc". *) FUNC p = InCenter(a, b, c) IS Angle.OnBisector(p, a, b, c) AND Angle.OnBisector(p, b, a, c) END; UI PointTool(InCenter); (* "p" is the center of the circle inscribed in the triangle "abc". *) FUNC res = Area(a, b, c) IS (E ab = R2.Minus(b, a), ac = R2.Minus(c, a), det = R2.Det(ab, ac) :: res = Math.Abs(det) / 2) END; (* "res" is the area of the triangle "abc". *)