5
$\begingroup$

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?

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

2 Answers 2

4
$\begingroup$
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"]}]
$\endgroup$
1
$\begingroup$

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}}]]]

triangle

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.