1

I would like to draw a circle within triangle. In this case, I make it from 3 points.

then I followed program below:

pA = {-21.7624, 48.8792}; pB = {-20.8074, 49.6132}; pC = {-20.9061, 49.2516};

lr = MeshRegion[{pA, pB, pC}, Triangle[Range@3]]; r1 = RegionDistance[InfiniteLine[{pA, pB}], {x, y}]; r2 = RegionDistance[InfiniteLine[{pB, pC}], {x, y}]; r3 = RegionDistance[InfiniteLine[{pC, pA}], {x, y}]; centerC = {x, y} /. NSolve[{r1 == r2, r2 == r3}, {x, y}, Reals]; centerC = Select[centerC, RegionMember[lr, #] &][[1]] raioC = RegionDistance[Line[{pA, pB}], centerC] Graphics[{EdgeForm[{Thick, Blue}], White, Triangle[{pA, pB, pC}], PointSize[Large], Red, Point@centerC, Red, Circle[centerC, raioC]}]

enter image description here

But I don't know how to take circle data points and the intersection point between a circle and triangle.

R.G.
  • 31
  • 2

1 Answers1

6

Use Insphere and RegionNearest:

pA={-21.7624,48.8792}; pB={-20.8074,49.6132}; pC={-20.9061,49.2516};

sphere = Insphere[{pA,pB,pC}]
center = First @ sphere;

pAB = RegionNearest[Line[{pA,pB}], center]
pBC = RegionNearest[Line[{pB,pC}], center]
pCA = RegionNearest[Line[{pC,pA}], center]

Sphere[{-20.9971, 49.3304}, 0.108585]

{-21.0633, 49.4165}

{-20.8924, 49.3018}

{-20.9538, 49.2308}

Visualization:

Graphics[{
    EdgeForm[Black], FaceForm[Green], Triangle[{pA,pB,pC}],
    sphere,
    PointSize[Large], Red, Point[{pAB,pBC,pCA}]
}]

enter image description here

Another possibility is to use RegionIntersection between the triangle and the circle, but that approach suffers from precision issues.

Carl Woll
  • 130,679
  • 6
  • 243
  • 355