Using the advice given here, I have a right triangle given by

plotRightTriangle[x_, y_] := 
 Graphics[{FaceForm[], EdgeForm[Black], 
Triangle[{{0, 0}, {x, 0}, {x, y}}]}, 
   Epilog -> {Inset[Style["a", 15], {x/2, 1/2}], 
 Inset[Style["b", 15], {x - 1/2, y/2}], 
       Inset[Style["c", 15], {x/2 - 1/2, y/2 + 1/2}]}]

plotRightTriangle[15, 8]

enter image description here

I would like to make two changes:

  1. put the labels "a" and "b" outside the triangle instead of inside (when I change the coordinates of the label, the label just disappears because outside the area of the graphic)
  2. mark each angle - a small square at ab, and small arcs at ac and bc.

How do I do this?


If I have started the wrong way, please feel free to set me on a better path!

  • $\begingroup$ 1. Don't use Epilog but put it next to the triangle, plot range will adapt automatically then. 2. the command for a square is Rectangle and an arc is a Circle with a third parameter. p.s. if you have v12 you can play with GeometricScene. $\endgroup$
    – Kuba
    Commented May 9, 2019 at 10:24

1 Answer 1

plotRightTriangle[x_, y_, r_: 2, s_: .1] := Module[{t=Triangle[{{0, 0}, {x, 0}, {x, y}}]},
  Graphics[{FaceForm[], EdgeForm[Black], t,
   Inset[Style["a", 15], {x/2, 0}, {0, 2}], 
   Inset[Style["b", 15], {x , y/2}, {-3, 0}], 
   Inset[Style["c", 15], {x/2 - 1/2, y/2 + 1/2}], 
   CapForm["Butt"], Thick, Orange, 
   RegionIntersection[t, Circle[{x, y}, r]], 
   RegionIntersection[t, Circle[{0, 0}, r]], Red, 
   Line[{{(1 - s) x, 0}, {(1 - s) x, s x}, {x, s x}}]}, 
  PlotRangePadding -> Scaled[.1]]]

plotRightTriangle[15, 8]

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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