標準座標系から特定の座標系にポイントを転送するコードがいくつかあります (ただし、Y は画面内で下方に増加するため、いくつかの調整が行われ、コメントが付けられました)。
ここで、double[] は点を表し、インデックス 0 は X 座標、インデックス 1 は Y です。新しい座標系の角度は反時計回りにラジアン単位で測定されることに注意してください。(度をラジアンに変換するには、Pi/180 を掛けます)。
/// <summary>
/// Implemented - Returns the point coordinates related to a new coordinate system
/// Does not change original point
/// </summary>
/// <param name="Point">Point to be returned in new coordinate system</param>
/// <param name="NewSystemCouterClockRotation">CounterClokWise Angle of rotation of the new coordinate system compared to the current, measured in radians</param>
/// <param name="NewSystemOrigin">Location of the new origin point in the current coordinate system</param>
/// <returns></returns>
public double[] ChangeCoordinateSystem(double[] Point, double NewSystemCouterClockRotation, double[] NewSystemOrigin)
{
//first adjust: fix that winform downwards increasing Y before applying the method
Point[1] = -Point[1];
NewSystemOrigin[1] = -NewSystemOrigin[1]
//end of first adjust
//original method
double[] Displacement = new double[2] { Point[0] - NewSystemOrigin[0], Point[1] - NewSystemOrigin[1] };
double[] Result = new double[2]
{
+ Displacement[0] * Math.Cos(NewSystemCouterClockRotation) + Displacement[1] * Math.Sin(NewSystemCouterClockRotation),
- Displacement[0] * Math.Sin(NewSystemCouterClockRotation) + Displacement[1] * Math.Cos(NewSystemCouterClockRotation)
};
//second adjust: reset Y of the result
Result[1] = - Result[1];
return Result;
}
ただし、2 つのオブジェクトの角度が異なる場合は注意が必要です。これを行う最善の方法all four corners of the first
は、最初の長方形が他のオブジェクトの内側にないかどうか、および最初の長方形の内側にもないかどうかを確認することthe other object four corners
です。
ポイントがポリゴンの内側にあるかどうかを調べるアルゴリズムは、次の場所にあります: ポリゴン内の
ポイント