OpenGL图像对称(反射)

反射其实就是关于平面xy的某条轴对称,如下式关于x,y对称:

void reflectionX() {//reflection around x
    GLint length = sizeof(point) / sizeof(point[0]);
    for(GLint i = 0; i < length; ++i) {
        GLfloat itemp = point[i].fy;
        point[i].fy = point[i].fx;
        point[i].fx = itemp;
    } 
}

void reflectionY() {//reflection around y
    GLint length = sizeof(point) / sizeof(point[0]);
    for(GLint i = 0; i < length; ++i) {
        point[i].fx = -point[i].fx;
    } 
}

1,关于原点对称,其实就是在当前位置旋转180度,根据旋转公式就可以得到原点对称抽后的图像。

2,关于某条直线对称对称只要利用:y = k*x + b,公式得到反射后的图像了。


你可能感兴趣的:(cocos2dx学习,OpenGL学习)