一、旋转点坐标映射公式
逆时针旋转:
x'=x*cos(a)-y*sin(a);
y'=x*sin(a)+y*cos(a);
-----------------------------
正向映射公式,同时引入旋转中心平移:
x'= (x - rx0)*cos(RotaryAngle) + (y - ry0)*sin(RotaryAngle) + rx0 ;
y'=-(x - rx0)*sin(RotaryAngle) + (y - ry0)*cos(RotaryAngle) + ry0 ;
-------------------------------
反向映射公式:
x=(x'- rx0)*cos(RotaryAngle) - (y'- ry0)*sin(RotaryAngle) + rx0 ;
y=(x'- rx0)*sin(RotaryAngle) + (y'- ry0)*cos(RotaryAngle) + ry0 ;
-----------------------------------
加入考虑坐标平移和缩放:
x=(x'- move_x-rx0)/ZoomX*cos(RotaryAngle) - (y'- move_y-ry0)/ZoomY*sin(RotaryAngle) + rx0 ;
y=(x'- move_x-rx0)/ZoomX*sin(RotaryAngle) + (y'- move_y-ry0)/ZoomY*cos(RotaryAngle) + ry0 ;
二、公式推导
假设对图片上任意点(x,y),绕一个坐标点(rx0,ry0)逆时针旋转a角度后的新的坐标设为(x0, y0),有公式:
x0= (x - rx0)*cos(a) - (y - ry0)*sin(a) + rx0 ;
y0= (x - rx0)*sin(a) + (y - ry0)*cos(a) + ry0 ;
在平面中,一个点绕任意点旋转θ度后的点的坐标_百度经验 https://jingyan.baidu.com/article/2c8c281dfbf3dd0009252a7b.html
【参考资料】
任意角度的高质量的快速的图像旋转 上篇 纯软件的任意角度的快速旋转 - 裴银祥的博客园 - 博客园 https://www.cnblogs.com/yinxiangpei/articles/3267267.html
中篇 高质量的旋转 - 裴银祥的博客园 - 博客园 https://www.cnblogs.com/yinxiangpei/articles/3267272.html
图像旋转的原理,实现与优化 - CSDN博客 https://blog.csdn.net/qianqing13579/article/details/52504089
快速图像旋转算法的c++实现 - CSDN博客 https://blog.csdn.net/xiaoheiblack/article/details/79026239
python 简单图像处理4旋转-echojb.com http://www.echojb.com/image/2016/11/14/258268.html
C++和matlab-图像旋转 - Qingsong_Zhao - 博客园 https://www.cnblogs.com/QingsongZhao-siat/p/8643082.html
图像处理学习笔记之图像的几何变换(3)旋转变换 - CSDN博客 https://blog.csdn.net/linshanxian/article/details/68944748
(实验二) --- 图像旋转变换---matlab实现 - CSDN博客 https://blog.csdn.net/abee23/article/details/7398749
【其他】
matlab练习程序(图像旋转,双线性插值) - Dsp Tian - 博客园 https://www.cnblogs.com/tiandsp/archive/2012/12/03/2800373.html
matlab练习程序(图像旋转,最邻近插值) - Dsp Tian - 博客园 http://www.cnblogs.com/tiandsp/archive/2012/03/08/2385369.html