围绕其中心旋转多边形

问题描述

我目前正在研究多边形旋转算法。考虑到左上角是(0,0); v[]一个顶点数组;而center是多边形的中心。

我试图绕中心旋转,但是下面的代码导致绕(0,0)旋转,我也不知道为什么。

float ox,oy,tx,ty;
    for (int i = 0; i < vnum; i++){
//translate vertice to (0,0)
        ox = v[i].x - center.x;
        oy = v[i].y - center.y;
//calculate rotated coordinates
        tx = ox * cos(degree) - oy * sin(degree);
        ty = ox * sin(degree) + oy * cos(degree);
//retranslate vertice to center
        v[i].x = tx + center.x;
        v[i].y = ty + center.y; 
    }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)