如何使用三角函数(Java)旋转原点周围的点阵列?

时间:2015-03-25 01:11:52

标签: java

    void RotateZ(double theta) {
    double sinTheta = Math.sin(theta);
    double cosTheta = Math.cos(theta);
    for (int v = 0; v < vertices.length; v++) {
        int x = vertices[v][0]; //current x of vertices v
        int y = vertices[v][1]; //current y of vertices v
        vertices[v][0] = (int) (x * cosTheta - y * sinTheta); //new x of vertices v
        vertices[v][1] = (int) (y * cosTheta + x * sinTheta); //new y of vertices v
    }
}

形状完全脱离屏幕,我不知道为什么。

0 个答案:

没有答案