2013-07-18 35 views
0

旋转后的新坐标我在那里我使用多个图像的草图。其中一幅图像正在翻译和旋转。 PopMatrix后我怎么知道已经围绕移动图像的新位置(X.Y)?如何知道在处理2

回答

0

你必须使用modelX()modelY()。请参见下面的示例,其绘制椭圆而不是图片:

void setup(){ 
    size(600, 600, P2D); 
    ellipseMode(CENTER); 
    pushMatrix(); 
    translate(width/2, height/2); 
    rotate(1.23); 
    int x1 = 100, y1 = 100; 
    ellipse(x1, y1, 10, 10); 
    // store translated/rotated coordinates 
    float x2 = modelX(x1, y1, 0); 
    float y2 = modelY(x1, y1, 0); 
    popMatrix(); 

    // draw red dot with stored coordinates 
    stroke(255, 0, 0); 
    ellipse(x2, y2, 2, 2); 
} 
相关问题