Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/348.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 偏移旋转_Java_Rotation_Offset - Fatal编程技术网

Java 偏移旋转

Java 偏移旋转,java,rotation,offset,Java,Rotation,Offset,我有一个在俄罗斯方块游戏中旋转棋子的代码,但我不知道xOffset和yOffset变量的含义。你能给我解释一下吗?非常感谢 双xOffset=宽度/2.0-.5; 双Y偏移=高度/2.0-.5 //Create a new body TPoint[] newBody = copyBody(body); for(TPoint p : newBody){ //Rotoate 90 degrees counter clockwise about the ori

我有一个在俄罗斯方块游戏中旋转棋子的代码,但我不知道xOffset和yOffset变量的含义。你能给我解释一下吗?非常感谢

双xOffset=宽度/2.0-.5; 双Y偏移=高度/2.0-.5

    //Create a new body
    TPoint[] newBody = copyBody(body);
    for(TPoint p : newBody){

        //Rotoate 90 degrees counter clockwise about the origin
        double newX = p.x;
        double newY = p.y;

        newX -= xOffset;
        newY -= yOffset;

        double temp = newX;
        newX = -newY;
        newY = temp;

        newX += yOffset;
        newY += xOffset;

        p.x = (int) newX;
        p.y = (int) newY;
    }
    return new Piece(newBody); 

仅仅通过阅读片段很难判断,但在我看来,
xOffset
yOffset
值指的是旋转的中心点