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:
- Construct equilateral triangles on two sides of our given (original) triangle.
- Connect the new vertexes with the opposite vertexes from the original triangle.
- 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:
- Calculate the coordinates of the third vertex in the equilateral triangles for two sides of the original triangle.
- 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.
- 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?
Best Answer
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+120^{\circ}):\csc(B+120^{\circ}):\csc(C+120^{\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.