6

I am aware of this question, but mine is a bit more specific.
I want to find the coordinates of the Fermat point for a given triangle. Assuming that no angle in the triangle is larger than 120 degrees, there's an algorithm for doing that that goes something like this:

  1. Construct equilateral triangles on two sides of our given (original) triangle.
  2. Connect the new vertexes with the opposite vertexes from the original triangle.
  3. Find the point in which the connecting lines intersect - that's the Fermat point of our original triangle.

(paraphrased from Wikipedia)

Now, I want to do this programmatically, so I can't do it by drawing. It would be ideal if I had a formula for the coordinates of the Fermat point, but I've tried Google and I can't find it.

Anyway, what I plan on doing is to write a program that does something like this:

  1. Calculate the coordinates of the third vertex in the equilateral triangles for two sides of the original triangle.
  2. Calculate the equations of the lines that connect the new vertexes with the opposite vertexes from the original triangle. I can do this because two point uniquely determine a line.
  3. Given the two line equations that I got in step 2, calculate the coordinates of the intersection of those lines.

Am I missing something? The fact that I can't find a formula for this makes me think that I am, because, if what I'm trying to do is correct, why isn't there a direct formula? I mean, what I'm doing in each step is basically using a formula on what I got from the previous step, so why wouldn't there be a formula to go from step 0 (coordinates of the original triangle) to step 3 (coordinates of the Fermat point)?

Furthermore, if there isn't a formula and if I'm not missing anything, is there a simpler way of doing what I'm trying to do?

iCanLearn
  • 181

2 Answers2

3

Reading farther on the Linked Wikipedia page, we have two cases:

Case 1: the triangle has an angle $\ge120^{\circ}$: the Fermat point is the obtuse-angled vertex.

Case 2: the triangle does not have an angle $\ge120^{\circ}$: the Fermat point is the first isogonic center. Following the link to this page, we find that point has trilinear coordinates $\csc(A+60^{\circ}):\csc(B+60^{\circ}):\csc(C+60^{\circ})$. If, like me, you are not familiar with trilinear coordinates, follow the link to its wikipedia page, where we find a method to convert trilinear coordinates to cartesian:

Taking vertex $C$ as the origin, find vectors $\vec{A}$ and $\vec{B}$ corresponding to the vertexes $A$ and $B$ respectively. Given side lengths $a, b, c$ corresponding in the usual way to the sides of the triangle respectively opposite vertices $A, B, C$, a trilinear coordinate $x:y:z$ is converted to a vector in cartesian coordinates by $$\vec{P}=\frac{ax}{ax+by+cz}\vec{A}+\frac{by}{ax+by+cz}\vec{B}.$$

In short, you have a piecewise function that checks for angle size and, if greater than 120 degrees, returns the $\vec{P}$, plus a correction $\vec{C}$ representing the location of $C$ if it is not convenient to have $C$ at the origin. You could embed the computation for $\vec{A}$ and $\vec{B}$ into the formula to have a single function result. That computation is necessary only if you don't already have coordinates for the vertices, and is elementary trig.

Oscar Lanzi
  • 39,403
rperce
  • 149
  • The trilinear coordinates above are incorrect: they should be $$\csc(A+60^{\circ}):\csc(B+60^{\circ}):\csc(C+60^{\circ}).$$ – user3473141 May 04 '17 at 17:02
  • 1
    The referenced page actually has the correct arguments, which it reports using radians rather than degrees as the angular unit (thus $\pi/3$ in place of $60°$). The original posting had made a wrong conversion from radians to degrees. – Oscar Lanzi Jun 13 '23 at 15:06
0

I tried the above solution, but couldn't get it to work. This Mathematica code by E. Coiras uses two inline functions and was fast enough for me, so I translated it to Matlab as shown below. I verified the solution over 100 random triangles by computing the three angles from the returned firstFermatPoint between the triangle vertices.

    function firstFermatPoint = calculateFermatPoint(A,B,C)
    % Returns the first Fermat point of a triangle with vertices (A,C,B).
Ax = A(1); Ay = A(2);
Bx = B(1); By = B(2);
Cx = C(1); Cy = C(2);

a = sqrt( (By-Cy)^2 + (Bx-Cx)^2 ); % side length opposite vertex A
b = sqrt( (Ay-Cy)^2 + (Ax-Cx)^2 ); % side length opposite vertex B
c = sqrt( (By-Ay)^2 + (Bx-Ax)^2 ); % side length opposite vertex C

% barycentric coordinates of the FIC:
fabc = firstIsogonicCenter(a,b,c);
fbca = firstIsogonicCenter(b,c,a);
fcab = firstIsogonicCenter(c,a,b);
fic1 = fabc/(fabc + fbca + fcab);
fic2 = fbca/(fabc + fbca + fcab);

% barycentric coordinates of the FFP:
ffp1 = median3(0.0, fic1, 1.0);
ffp2 = median3(0.0, fic2, 1.0);
ffp3 = 1.0 - ffp1 - ffp2;
% return Cartesian coordinates of the FFP:
firstFermatPoint =  A*ffp1 + B*ffp2 + C*ffp3;

    function med = median3(a,b,c)
        % Closed formula for the median of three scalars:
        med = (2*a + 2*b + abs(a + b - 2*c - abs(a - b)) - abs( a + b - 2*c + abs(a - b)))/4;
    end

    function fic =  firstIsogonicCenter(a,b,c)
        % base formula for the FIC (first isogonic center):
        fic = a^4 - 2*(b^2 - c^2)^2 + ...
              a^2*(b^2 + c^2 + ...
              sqrt(3*(-a + b + c)*(a + b - c)*(a - b + c)*(a + b + c)));
    end

end