Fermat Point, version 1.0, 2025-12-15
Rolf Puetter

Let a set S of n points (n>=3) be given in the Euclidean plane. The point x that minimizes the sum of the distances of
x to the points of S is called the Fermat point of S. If n=3, the points of S form a triangle T and x is the Fermat point of 
T. If all the inner angles of T are <120°, then the line segments of x to the vertices of T meet at equal angles (120°).
If n=4 and the points of S form a convex quadrilateral, x coincides with the intersection point of the quadrilateral's 
diagonals.
For a convex hexagon ABCDEFG, the following can be proved: x lies inside the triangle formed by the diagonals AE, BF, CG.
To illustrate this fact, the program, for n=6, displays these diagonals in blue. The program computes the Fermat point by
a simple approximation procedure (move x along the negative gradient) and draws it as a blue cross. It also computes the 
center of gravity of S and shows it as a green cross.
The sum of the distances is displayed in the upper left corner of the screen. You can move the point x and see that the sum
increases as x moves away from its Fermat position.


Controls:

arrow keys:		move the marked point (the mark is a red circle around the point)
tab key:	        toggle mark through the points
ESC, Backspace		delete marked point if it's not x and if at least three points are left in S
[a]...[j]		create a new point with this name in case it doesn'exist yet. Otherwise mark that point
[s]:			make a step of approximation of x towards the Fermat point (if it's not in place)
[r]:			move x back to the Fermat position
[n]:			back to starting configuration
[z]:			show/hide coordinate system