# Drawing two altitudes of a triangle

I am trying to construct a triangle with 2 altitudes. It worked for 'All' vertices.

a = {5, 0};
b = {0, 0};
c = {3, 6};
tri = {a, b, c};
alt = TriangleConstruct[tri, {"Altitude", All}];
Graphics[{Style[Triangle[tri], Opacity[0.2]], alt}]


But when I tried to specify two vertices,

alt = TriangleConstruct[tri, {"Altitude", {a, b}}]


The following message came out:

TriangleConstruct is not a Graphics primitive or directive.


How do I specify two vertices to draw the altitudes?

I have also tried the following:

RandomInstance[GeometricScene[{a,b,c,d}, {d == TriangleConstruct[{a,b,c}, {"Altitude", a}]}]]


But the output was only:

RandomInstance[GeometricScene[{{a, b, c, d}, {}}, {d ==TriangleConstruct[{a, b, c}, {"Altitude", a}]}, {}]]


What went wrong?

• ClearAll[alt]; alt[p_]:= TriangleConstruct[tri, {"Altitude",p}]; Graphics[{Style[Triangle[tri], Opacity[0.2]],alt/@{a,b}}]
– kglr
Sep 20, 2020 at 5:05

a = {5, 0};
b = {0, 0};
c = {3, 6};
tri = {a, b, c};
TriangleConstruct[{a, b, c}, "Altitude"]
TriangleConstruct[{b, c, a}, "Altitude"]
TriangleConstruct[{c, a, b}, "Altitude"]

(* Line[{{0, 0}, {9/2, 3/2}}];
Line[{{3, 6}, {3, 0}}];
Line[{{5, 0}, {1, 2}}]
*)


So

a = {5, 0};
b = {0, 0};
c = {3, 6};
tri = {a, b, c};
alt = TriangleConstruct[tri, {"Altitude", All}];
Graphics[{Style[Triangle[tri], Opacity[0.2]],
TriangleConstruct[{a, b, c}, "Altitude"],
TriangleConstruct[{b, c, a}, "Altitude"]}]


I would do it this way. I'm using the method suggested by kglr in his comment, but with some care taken with scoping niceties such as localizing variables and eliminating the free variable from alt.

Clear[alt]
alt[p_, tri_] := TriangleConstruct[tri, {"Altitude", p}]
With[{a = {5, 0}, b = {0, 0}, c = {3, 6}},
Module[{tri = {a, b, c}},
Graphics[{Style[Triangle[tri], Opacity[0.2]], alt[#, tri] & /@ {a, b}}]]]