2
$\begingroup$

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.

enter image description here

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

$\endgroup$

2 Answers 2

12
$\begingroup$

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
    ]
]

enter image description here

$\endgroup$
8
$\begingroup$
$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 *)
$\endgroup$

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.