One easy problem and One not so easy problem.

A few post ago we used Mathematica to draw the altitudes of an arbitrary triangle of given coordinates. Now we are solving these other two problems The first figure the red lines represent the medians and on the second figure the yellow lines represent the angle bisectors. So our problem consist in finding the Mathematica code to produce these figures.

Let us do the easy one first. To draw a triangle and the medians we will use the Lineal Bezier equation we have use before and since we are interested in finding the mid points on each side the resulting Mathematica code is very simple.

a = {0, 0};
b = {3, 0};
c = {1, 2};
BAB[t_, a_, b_] := (1 – t) a + t b;
Graphics[{Background -> Black,
{{Thick, Blue, Line[{a, b, c, a}]},
{Thick, Red, Line[{c, BAB[1/2, a, b]}]},
{Thick, Red, Line[{a, BAB[1/2, c, b]}]},
{Thick, Red, Line[{b, BAB[1/2, c, a]}]}
},
Inset[Text[Style["A", White, Italic, Large]], {-.1, 0}],
Inset[Text[Style["B", White, Italic, Large]], {3.1, 0}],
Inset[Text[Style["C", White, Italic, Large]], {1.1, 2.1}]}]

Now for the angle bisectors it is a bit harder. We are going to need some property the bisectors satisfy that will allow us to get the coordinates of the intersection of each bisector with each of the sides. One property that could help us is this one.

Theorem: For a triangle ABC If CQ is the bisector thru the angle ACB then AC/CB=AQ/QB.

Notice we will need to find some distances between sides that are given by coordinates so the function EuclideanDistance will be of help. Since we can easily compute AC/CB we need to find Q in AB such that AQ/QB is equal to AC/CB but this is not difficult to achieve if we use the function Nearest. We can guess the best value of Q by building a table where Q is going from A to B and then we pick the best value that approaches to the ratio AC/CB. We can accomplished that with the following Mathematica Code.

a = {0, 0};
b = {3, 0};
c = {1, 2};
ac = EuclideanDistance[a, c];
bc = EuclideanDistance[b, c];
ab = EuclideanDistance[a, b];
cc = ac/bc;
BAB[t_, a_, b_] := (1 – t) a + t b;
N[cc];
tabl = Table[
EuclideanDistance[a, BAB[t, a, b]]/
EuclideanDistance[b, BAB[t, a, b]], {t, 0.000001, 1, 0.001}];
nearest = Nearest[tabl, N[cc]];
Flatten[Position[tabl, First[nearest]]]

that will give us the value 443 that we will use in conjunction with the 0.001 doing similarly for the other sides of the triangle we get the very compact solution

a = {0, 0};
b = {3, 0};
c = {1, 2};
BAB[t_, a_, b_] := (1 – t) a + t b;
Graphics[{Background -> Black,
{{Thick, Blue, Line[{a, b, c, a}]},
{Thick, Yellow, Line[{c, BAB[443*0.001, a, b]}]},
{Thick, Yellow, Line[{a, BAB[428*0.001, c, b]}]},
{Thick, Yellow, Line[{b, BAB[486*0.001, c, a]}]}
},
Inset[Text[Style["A", White, Italic, Large]], {-.1, 0}],
Inset[Text[Style["B", White, Italic, Large]], {3.1, 0}],
Inset[Text[Style["C", White, Italic, Large]], {1.1, 2.1}]}]

Again this time Nearest comes to the rescue and helps us get the best value from a list of possible values!

Leave a Reply