# How can I sketch a right-angled triangle?

I would like to replicate this ellipse, but with a right-angled triangle (with smooth/rounded corners).

The formula for this ellipse:

h = 3; k = 3; A = -60;

xN = ((x - h)*Cos[A] + (y - k)*Sin[A]);
yN = ((x - h)*Sin[A] + (y - k)*Cos[A]);

RegionPlot[1/3 <= (xN/2)^2 + (yN/1)^2 <= 4/3, {x, 0, 6}, {y, 0, 6}]


The reason for using RegionPlot is to remove the inner part of the ellipse. Is it possible to use this method to get a right-angled triangle, but with rounded corners like this?

tri = AASTriangle[Pi/2, Pi/4, 1];

srd = SignedRegionDistance[tri];


We can use SignedRegionDistance with ContourPlot or with RegionPlot (this would be very slow):

ContourPlot[srd[{x, y}], {x, -.2, 1}, {y, -.2, 1},
Contours -> {.1, .02},
ImagePadding -> 10, Frame -> False, ImageSize -> Large]


RegionPlot[.02 <= srd[{x, y}] <= .1, {x, -.2, 1}, {y, -.2, 1},
PlotStyle -> Yellow, PlotPoints -> 80, ImagePadding -> 10,
Frame -> False, ImageSize -> Large]


We can also use the function explode from this answer to rescale the contour lines while preserving rounded corners:

ClearAll[explode, bsf]
explode[f_] := f[#] + #2 Cross @ Normalize[f'[#]] &;

cp0 = ContourPlot[srd[{x, y}], {x, -.1, .8}, {y, -.1, .8},
Contours -> {.05}, ContourShading -> None];

mc = MeshCoordinates@DiscretizeGraphics[cp0];

bsf = BSplineFunction[mc, SplineClosed -> True];

Graphics[{Thick, BSplineCurve[mc, SplineClosed -> True],
Blue, Line[explode[bsf][#, .1] & /@ Subdivide[200]]}]


Graphics[{Black, Thick, BSplineCurve[mc, SplineClosed -> True],
Line[explode[bsf][#, .1] & /@ Subdivide[200]],
Red, FilledCurve[{BSplineCurve[mc, SplineClosed -> True],
Line[explode[bsf][#, .1] & /@ Subdivide[200]]}]}]


Updated

pts = {{0, 0}, {2, 0}, {0, 4}};
in = {.7, 1};
smallpts = Mean[{#, in}] & /@ pts;
Graphics[{Orange, EdgeForm[{JoinForm["Round"], Thickness[0.035]}],
FilledCurve[{{Line[pts]}, {Line[smallpts]}}]}]


Original

pts = {{0, 0}, {2, 0}, {0, 4}};
in = {.7, 1};
smallpts = Mean[{#, in}] & /@ pts;
Graphics[{Red, Point[in], Green, Polygon[pts -> {smallpts}]}]


Or

pts = {{0, 0}, {2, 0}, {0, 4}};
in = {.7, 1};
smallpts =
Mean[{#, in}] & /@ pts;
Graphics[{Orange,
FilledCurve[{{Line[pts]}, {Line[smallpts]}}]}]

• pts = {{0, 0}, {1, 0}, {0, 2}}; Graphics[{FaceForm[], EdgeForm[{JoinForm["Round"], Thickness[0.155], Brown}], Polygon[pts], EdgeForm[{Yellow, Thick}], Polygon[pts]}, PlotRange -> All, PlotRangePadding -> 0.5] Commented Nov 28, 2020 at 11:37

For a hand-drawn sketch look:

Graphics[{AbsoluteThickness[30], ColorData[97]@1, CapForm["Round"],
JoinForm["Round"], Line[{{0, 0}, {1/Sqrt[2], 0}, {0, 1/Sqrt[2]}, {0, 0}}]},
ImagePadding -> 30] // ImageEffect[#, {"Jitter", 5}] &