/// <summary>
/// 对一个坐标点按照一个中心进行旋转
/// </summary>
/// <param name="x">坐标x</param>
/// <param name="y">坐标y</param>
/// <param name="angle">旋转角度</param>
/// <param name="tmpX">返回坐标x</param>
/// <param name="tmpY">返回坐标y</param>
/// <param name="centerX">中心点x(默认0)</param>
/// <param name="centerY">中心点y(默认0)</param>
public static void RotateCenter(double x, double y, double angle, out double tmpX, out double tmpY, double centerX = 0, double centerY = 0)
{
tmpX = 0;
tmpY = 0;
try
{
double angleHude = angle * Math.PI / 180;/*角度变成弧度*/
double x1 = (x - centerX) * Math.Cos(angleHude) + (y - centerY) * Math.Sin(angleHude) + centerX;
double y1 = -(x - centerX) * Math.Sin(angleHude) + (y - centerY) * Math.Cos(angleHude) + centerY;
tmpX = x1;
tmpY = y1;
}
catch (Exception ex)
{
}
}
/// <summary>
/// 对一个坐标点按照一个中心进行旋转
/// </summary>
/// <param name="originalPoint">原坐标</param>
/// <param name="angle">旋转角度</param>
/// <param name="centerPoint">中心坐标</param>
/// <returns></returns>
public static Point RotateCenter(Point originalPoint, double angle, Point centerPoint)
{
Point tmpPoint = new Point(0,0);
try
{
double angleHude = angle * Math.PI / 180;/*角度变成弧度*/
double x1 = (originalPoint.X - centerPoint.X) * Math.Cos(angleHude) + (originalPoint.Y - centerPoint.Y) * Math.Sin(angleHude) + centerPoint.X;
double y1 = -(originalPoint.X - centerPoint.X) * Math.Sin(angleHude) + (originalPoint.Y - centerPoint.Y) * Math.Cos(angleHude) + centerPoint.Y;
tmpPoint.X = (int)x1;
tmpPoint.Y = (int)y1;
}
catch (Exception ex)
{
}
return tmpPoint;
}
标签:angleHude,C#,double,旋转,originalPoint,坐标,centerPoint,Math
From: https://www.cnblogs.com/qiutian-hao/p/18383885