Skip to main content

graphics - How to draw right angled triangle with a, b and c lengths shown?



I'm trying to draw a right angled triangle with hypotenuse length 1,opposite length b and adjacent length c in Mathematica. How do I do this? I'm trying to draw an isosceles triangle showing length 1 for hypotenuse and side a and side b for other sides.



Answer



Here's a suggestion for a function which takes arbitrary x and y lengths, and plots a right triangle with those values. Adjust the styling/options as desired.


plotTriangle[x_, y_] := 
Graphics[{Red, Thick,
Line /@ {{{0, 0}, {x, 0}}, {{0, 0}, {0, y}}, {{x, 0}, {0, y}}}},
Axes -> True,
Epilog -> {Inset[Style["a", 20, Red], {x/2, 0 + y/15}],
Inset[Style["b", 20, Red], {x/15, y/2}],
Inset[Style["1", 20, Red], {x/2 + x/15, y/2 + y/15}]}]


enter image description here


Comments