在下面的图示中,我需要找到从A到B的弧线的中点M:
我想要根据以下信息找到M的坐标:
- A.X和A.Y,A的坐标 - B.X和B.Y,B的坐标 - Radius,弧线的半径 - Center.X和Center.Y,弧线的中心点
如何计算M的坐标?
![midpoint](https://i.imgur.com/KB7EqBv.png)
- A.X和A.Y,A的坐标 - B.X和B.Y,B的坐标 - Radius,弧线的半径 - Center.X和Center.Y,弧线的中心点
如何计算M的坐标?
A
,B
,M
和Center
是某种矢量类型的对象,并具有通常的操作:var a = A-C;
var b = B-C;
var m = a+b;
m
是一个从Center
指向M
的向量。因此:
m = m.Normalize() * Radius;
M = Center + m;
var angle = Math.Atan2(b.y, b.x) - Math.Atan2(a.y, a.x);
if (angle < 0)
{
angle = 2*Math.PI + angle;
}
a
按该角度的一半旋转:rotate
angle /= 2;
var m = a.Rotate(angle);
M = Center + m;