0
3點的負角我有3個點,X,Y座標的所有3檢索正的或從上圓
- 其中一點是圓的中心
- 其它兩個點被移動在這個圓上
我想找到方向移動時鐘或順時針我試着用矢量和這個link。
我總是角度上這種積極的座標:
- 從P1 P2 >>>>>>時鐘 中心(-1.236,6.937) P1(1113.749,3070.335) P2(2094.251,2504.242 )
順時針P3 P4 >>>>中心 (-1.236,6.937) P3(2479.926,1439.437) P4(1988.959,2067.846)
public static double AngleFrom3PointsInDegrees(double Xc, double Yc, double Xa, double Ya, double Xb, double Yb) { /* double Xc = centerPoint.X; double Yc = centerPoint.Y; double Xb = oldPoint.X; double Yb = oldPoint.Y; double Xa = newPoint.X; double Ya = newPoint.Y; */ double c2 = (Math.Pow(Xb - Xa, 2) + Math.Pow(Yb - Ya, 2)); double a2 = (Math.Pow(Xb - Xc, 2) + Math.Pow(Yb - Yc, 2)); double b2 = (Math.Pow(Xa - Xc, 2) + Math.Pow(Ya - Yc, 2)); double a = Math.Sqrt(a2); double b = Math.Sqrt(b2); double val = (a2 + b2 - c2)/(2 * a * b); double angle = Math.Acos(val); return angle = angle > Math.PI ? angle - 2 * Math.PI : angle; } public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { double Case1= AngleFrom3PointsInDegrees(-1.236,6.937,1113.749,3070.335,2094.251,2504.242); double Case2 = AngleFrom3PointsInDegrees(-1.236, 6.937, 247.926, 1439.437, 1988.959, 2067.846); MessageBox.Show("Angle = " + Case1); MessageBox.Show("Angle = " + Case2);