コメントで述べたように、含まれている関数の計算は問題ありません。回転したポイントは期待どおりに計算されます (負の角度は時計回りの回転を意味します)。あなたが求めているのは、極座標系に基づく回転点の定義であり、これは後の段階で行う必要があります。「望ましい」に描かれている基準系は、「既定の基準系」に対して +90 度のギャップがあるため、そのようなシステムに対して実行される計算に +90 を追加するだけで済みます。
あなたが求めている角度は、次の関数に依存して計算できます。
public static double angleFromPoint(Point inputPoint, Point centerPoint)
{
double varX1 = Math.Abs(inputPoint.X - centerPoint.X);
double varY1 = Math.Abs(inputPoint.Y - centerPoint.Y);
double outAngle = 180 * Math.Atan(varY1 / varX1) / Math.PI; //Angle from 0 to 90 which has to be updated on account of the quadrant it is in and the chosen syst
int curQuadrant = determineQuadrant(inputPoint, centerPoint);
//Modifications to account for the default system of reference
if (curQuadrant == 1)
{
outAngle = 180 - outAngle;
}
else if (curQuadrant == 3)
{
outAngle = 360 - outAngle;
}
else if (curQuadrant == 4)
{
outAngle = 180 + outAngle;
}
//Over-modification to account for the system of reference "Desired", +90 the default system of reference
outAngle = outAngle + 90;
if (outAngle > 360)
{
outAngle = outAngle - 360;
}
return outAngle;
}
//Moving clockwisely, the first quadrant is located between 180 and 90 degrees in the default system of reference
public static int determineQuadrant(Point inputPoint, Point centerPoint)
{
int curQuadrant = 0;
if (inputPoint.X < centerPoint.X && inputPoint.Y >= centerPoint.Y)
{
//Default system of reference -> 180 to 90
curQuadrant = 1;
}
else if (inputPoint.X >= centerPoint.X && inputPoint.Y >= centerPoint.Y)
{
//Default system of reference -> 90 to 0/360
curQuadrant = 2;
}
else if (inputPoint.X >= centerPoint.X && inputPoint.Y < centerPoint.Y)
{
//Default system of reference -> 0/360 to 270
curQuadrant = 3;
}
else if (inputPoint.X < centerPoint.X && inputPoint.Y < centerPoint.Y)
{
//Default system of reference -> 270 to 180
curQuadrant = 4;
}
return curQuadrant;
}
そこでは、「デフォルトの参照システム」に基づいた段階的で明確な計算と、その後の必要なものへの変換を確認できます。計算は ArcTangent (0 ~ 90 の角度のみを提供) に基づいており、指定された「象限」 (既定のシステム、つまり目的のシステムの -90 に基づく) に基づいて更新されます。計算された角度 + 90 により、必要な結果が得られます。
したがって、最初に回転したポイントの座標を計算し、次に関連する角度を計算する必要があります。
Point rotatedPoint = RotatePoint(curPointnew, centerPoint, rotationAngle);
double angleRotatedPoint = angleFromPoint(rotatedPoint, centerPoint);