# How to get a perpendicular segment inside of a triangle

I created a graphic to obtain a triangle with three vertices.

The code is as follows:

a = {4, 2, 1}; b = {1, 0, 1}; c = {1, 2, 0};

Graphics3D[{
Text[Style["A", Large, Bold, Red], {4.28, 2.09, 1.05}],
Text[Style["B", Large, Bold, Red], {0.86, -0.25, 1.08}],
Text[Style["C", Large, Bold, Red], {0.81, 2.18, -0.15}],
Blue,
PointSize[.05], Point[a], Point[b], Point[c],
Black,
Line[{a, b, c, a}]
}]


What would be the coordinate on the segment BC which forms another perpendicular segment through the point A?

• I was already doing it. the smartphone is slower. :) Aug 27, 2016 at 18:14
• You mean the projection of A onto BC? Aug 27, 2016 at 19:33
• Yes. This projection forming 90 degree with BC. Aug 27, 2016 at 19:51
• Have you seen Projection[]? Aug 27, 2016 at 20:01

Using b as the origin:

p=Projection[a - b, c - b] + b;


Which is the same as:

p = ((a - b).(c - b) (c - b))/EuclideanDistance[b, c]^2 + b;

Graphics3D[{Text[Style["A", Large, Bold, Red], {4.28, 2.09, 1.05}],
Text[Style["B", Large, Bold, Red], {0.86, -0.25, 1.08}],
Text[Style["C", Large, Bold, Red], {0.81, 2.18, -0.15}], Blue,
PointSize[.05], Point[a], Point[b], Point[c], Point[p], Black,
Line[{a, b, c, a}], Thickness[0.02], Red, Dashed, Arrow[{b, p}],
Arrow[{a, p}]}]


Check:

Dot[p - b, a - p]


0

# 1. find the equation of the line through $b$ and $c$

a = {4, 2, 1};
b = {1, 0, 1};
c = {1, 2, 0};

line = t b + (1 - t) c;


# 2. find the shortest distance from $a$ to this line

p = line/.Last@Minimize[EuclideanDistance[{1, 2 (1 - t), t}, a], t]