计算一点绕另一点旋转一定角度后新点的坐标
using System;
namespace RotatePoint
{
class Program
{
static void Main(string[] args)
{
double X = 0;
double Y = 0;
RotateAngle(1, 1, -45, 2, 2, ref X, ref Y);
Console.WriteLine(X+","+Y);
Console.ReadKey();
}
public static string RotateAngle(double XRotation, double YRotation, double ARotate, double XBefore, double YBefore, ref double XAfter, ref double YAfter)
{
try
{
double Rad = 0;
Rad = ARotate * Math.Acos(-1) / 180;
XAfter = (XBefore - XRotation) * Math.Cos(Rad) - (YBefore - YRotation) * Math.Sin(Rad) + XRotation;
YAfter = (YBefore - YRotation) * Math.Cos(Rad) + (XBefore - XRotation) * Math.Sin(Rad) + YRotation;
return "OK";
}
catch (Exception ex)
{
return ex.Message;
}
}
}
}