# How to visualize the circle-triangle-probability problem

This 3b1b video talks about the following problem: given 3 random points on a circle, what is the probability that the triangle whose vertices are those points contains the center of the circle. To visualize the problem, he makes this interactive graphic, in which the points $$P_1,P_2,P_3$$ can be dragged around to see how the triangle is affected.

Is there a relatively beginner friendly way to program this in Mathematica?

This gives an interactive graphic to explore the topic. I use LocatorPane, Dynamic, and RegionMember. The starting point was this LocatorPane documentation example:

DynamicModule[
{pt = {{0, 1}, {1, 0}, {-1, 0}}},
LocatorPane[Dynamic @ pt,
Graphics[
{
{White, Circle[]},
{
PointSize @ Large, Yellow, Point @ {0, 0},
Dynamic @ Point @ Map[Normalize, pt]
},
{Red, Opacity @ 0.5, Dynamic @ Triangle @ Map[Normalize, pt]},
Inset[
Dynamic @ Style[
If[
RegionMember[Triangle @ Map[Normalize, pt], {0, 0}],
"center included", "center excluded"
],
15, Yellow
],
{0, 0.1}
]
},
Background -> Black
],
Appearance -> None
]
]

\$Version

(* "13.0.1 for Mac OS X x86 (64-bit) (January 28, 2022)" *)

Clear["Global`*"]

SeedRandom[1234];

With[{n = 10000},
Count[
Table[
RegionMember[
Triangle[
RandomPoint[Circle[], 3] (* 3 points on unit circle *)
] (* triangle formed by points *),
{0, 0}], (* test if origin is in triangle *)
{n}], (* do n times *)
True] (* count number of times True *)
/n] // N (* divide by number of trials and convert fraction to \
decimal *)

(* 0.253 *)