4

In the diagram below, I need to find the midpoint M of the arc from A to B:

midpoint

I want to find M in terms of the following information:

  • A.X and A.Y, the coordinates of A
  • B.X and B.Y, the coordinates of B
  • Radius, the radius of the arc
  • Center.X and Center.Y, the center of the arc

How do I compute the coordinates of M?

arghbleargh
  • 3,090
  • 21
  • 13
michaelbr92
  • 95
  • 1
  • 6

1 Answers1

6

Assuming A, B, M and Center are objects of some vector type with the usual operations:

var a = A-C;
var b = B-C;
var m = a+b;

m is a vector that goes from Center towards M. Therefore:

m = m.Normalize() * Radius;
M = Center + m;

Please note: This algorithm does not assume an order of A and B, and always interprets the arc as the smaller of the two possible ones. Without adding special cases, it can only handle arcs with an angle smaller than 180°.

To handle order: First calculate the angle from a to b using atan2:

var angle = Math.Atan2(b.y, b.x) - Math.Atan2(a.y, a.x);
if (angle < 0)
{
    angle = 2*Math.PI + angle;
}

Then rotate a by half that angle:

angle /= 2;
var m = a.Rotate(angle);
M = Center + m;
Community
  • 1
  • 1
Sebastian Negraszus
  • 11,915
  • 7
  • 43
  • 70
  • There's a better answer without goniometric calls that is https://stackoverflow.com/questions/4103405/what-is-the-algorithm-for-finding-the-center-of-a-circle-from-three-points?rq=1 – Goodies Apr 17 '18 at 21:05
  • 1
    @Goodies Center of a circle isn't center of an arc. – kagronick Feb 16 '21 at 03:42
  • @kagronic when the arc is *not* elliptical, we are talking about the same midpoint. The submit I refer to is a straightforward three points center calculation applicable on any circular segment. Call your math teacher if you think this is invalid. – Goodies Feb 16 '21 at 12:57
  • @Goodies The midpoint of an arc is on the edge of the circle, the center of the circle is in the middle of the circle. They are totally different things. And that question uses 3 points this uses 2 points and the radius. – kagronick Feb 16 '21 at 20:34
  • @kagronick you are right I confused M and center. But when the center (Xc, Zc) is known, the midpoint M of the arc above can be found easily as M=(Xc, Zc+distance(C, A)). When the arc is tilted, you can connect A and B, find the middle and orthogonal, normalize then multiply the vector with sagittal height to find M. In any case, calculating C first will help to find M too. – Goodies Feb 17 '21 at 09:55
  • http://mathcentral.uregina.ca/RR/database/RR.09.10/akulov2.html – Goodies Feb 17 '21 at 10:03