简单的点旋转
图片旋转,顺时针点旋转
其实很容易,把算法提出来后就那么一点点
用JAVA写了一遍
double PI = 3.14159265;
double angle = 0;
double angle_cos = 0;
double angle_sin = 0;
angle = 40 * PI / 180;
angle_cos = Math.cos(angle);
angle_sin = Math.sin(angle);
int x = 40;
int y = 20;
int mx = 10;
int my = 18;
x -= mx;
y -= my;
double newx = x * Math.cos(angle) + y * Math.sin(angle);
double newy = -x * Math.sin(angle) + y * Math.cos(angle);
newx += mx;
newy += my;
//x0cosa+y0sina
//-x0sina+y0cosa
System.out.println("angle:" + angle);
System.out.println("angle_cos:" + angle_cos);
System.out.println("angle_sin:" + angle_sin);
System.out.println("newx:" + newx);
System.out.println("newy:" + newy);