[Math] Formula for calculating the center of an arc

circlesgeometrytrigonometry

Is there a formula for calculating the point equidistant from the start point and end point of an arc given:

1) An arc is defined as: A center point $P$, a radius $r$ from the center, a starting angle $sA$ and an ending angle $eA$ in $radians$ where the arc is defined from the starting angle to the ending angle in a counter-clockwise direction.

2) The start point $sP$ is calculated as: $sP\{Px + \cos sA \times r, Py + -\sin sA \times r\}$

3) The end point $eP$ is calculated as: $eP\{Px + \cos eA \times r, Py + -\sin eA \times r\}$

Give the above restrictions, is there a way to calculate the point that is halfway between the start and end angles and exactly $r$ units away from the center?

Best Answer

Had an epiphany just as I hit submit, would this work?

$cP \{ Px +$ $\cos (eA - sA) \over 2$ $\times r, Py +$ $-\sin (eA - sA) \over 2$ $\times r\}$

SOLVED:

Using the piece-wise function:

$ cP( Px +$ $\cos($ $sA + eA \over 2$ $ + n) \times r, Py +$ $-\sin($ $sA + eA \over 2$ $ + n) \times r) = \begin{cases} n = 0, & \text{if }eA - sA \text{ is } >= 0 \\ n = \pi, & \text{if }eA - sA \text{ is } < 0 \end{cases} $

For you computer science-y types here's some pseudo-code:

double e = GetEndAngle();
double s = GetStartAngle();
double d = e - s;

double x = 0.0;
double y = 0.0;
double offset = 0.0;
if(d < 0.0) {
    offset = PI;
}
x = (GetPosition().GetX() + std::cos(((s + e) / 2.0) + offset) * GetRadius());
y = (GetPosition().GetY() + -std::sin(((s + e) / 2.0) + offset) * GetRadius());