Triangle Perimeter

Here is the mathematical way, how to calculate the center of three points (which define a circle).

A circle is through the origin is defined as:

\[ x^2 + y^2 = r^2 \]

The circle can be moved to a new center xm/ym:

\[ (x - x_m)^2 + (y - y_m)^2 = r^2 \]

Reordering this equation gives:

\[ x^2 + y^2 = 2 x_m x + 2 y_m y - y_m^2 - x_m^2 + r^2 \]

  1. With \[Q = r^2 - y_m^2 - x_m^2\] and \[S_i = x_i^2 + y_i^2\] and three points x1-3/y1-3 I get three equations with three unknowns (xm, ym, Q): \[ \begin{aligned} S_1 &=& 2 x_m x_1 + 2 y_m y_1 + Q & \quad (1a)\\ S_2 &=& 2 x_m x_2 + 2 y_m y_2 + Q & \quad (1b)\\ S_3 &=& 2 x_m x_3 + 2 y_m y_3 + Q & \quad (1c) \end{aligned} \]
  2. Subtracting equation 1a from the two others to eliminate Q \( \begin{aligned} S_1 &=& 2 x_m x_1 + 2 y_m y_1 + Q & \quad (2a)\\ S_2 - S_1 &=& 2 x_m (x_2 - x_1) + 2 y_m (y_2 - y_1) & \quad (2b) \\ S_3 - S_1 &=& 2 x_m (x_3 - x_1) + 2 y_m (y_3 - y_1) & \quad (2c) \end{aligned} \)

  3. Multiplying 2b by (y3 - y1) and 2c by (y2 - y1) \( \begin{aligned} S_1 &=& 2 x_m x_1 + 2 y_m y_1 + Q & \quad (3a)\\ (S_2 - S_1) (y_3 - y_1) &=& 2 x_m (x_2 - x_1) (y_3 - y_1) + 2 y_m (y_2 - y_1) (y_3 - y_1) & \quad (3b) \\ (S_3 - S_1) (y_2 - y_1) &=& 2 x_m (x_3 - x_1) (y_2 - y_1) + 2 y_m (y_3 - y_1) (y_2 - y_1) & \quad (3c) \end{aligned} \)

  4. Subtracting 3b from 3c and simplifying \( \begin{aligned} S_1 &=& 2 x_m x_1 + 2 y_m y_1 + Q & \quad (4a)\\ (S_2 - S_1) (y_3 - y_1) &=& 2 x_m (x_2 - x_1) (y_3 - y_1) + 2 y_m (y_2 - y_1) (y_3 - y_1) & \quad (4b) \\ S_1 (y_2 - y_3) + S_2 (y_3 - y_1) + S_3 (y_1 - y_2) &=& 2 x_m (x_1 (y_2 - y_3) + x_2 (y_3 - y_1) + x_3 (y_1 - y_2)) & \quad (4c) \end{aligned} \)

  5. Equation 4c now contains only the unknown xm:

\[ x_m = \frac{S_1 (y_2 - y_3) + S_2 (y_3 - y_1) + S_3 (y_1 - y_2)}{2(x_1 (y_2 - y_3) + x_2 (y_3 - y_1) + x_3 (y_1 - y_2))} \quad (5) \]

  1. Equation 2b contains the unknowns ym and xm and with xm from 5

\[ y_m = \frac{S_2 - S_1 - 2 x_m (x_2 - x_1)}{2 (y_2 - y_1)} \quad (6) \]

  1. Solving 1a and with \[Q = r^2 - y_m^2 - x_m^2\] gives

\[ r = \sqrt{S_1 - 2 x_m x_1 - 2y_m y_1 + y_m^2 + x_m^2} \quad (7) \]

An similar example with numbers (in german only) can be found here: Kreis durch drei Punkte. One can also solve it geometrically, by drawing orthogonal lines through the center of each triangle side.The center of the perimeter is, where these lines intersect.