회전 기능을 사용하지 않고 직사각형을 회전하려고하지만 대신 행렬을 사용하고 있습니다. 행렬을 사용하여 선을 회전하는 방법을 알고 있지만 직사각형을 회전하려는 모든 시도가 실패했습니다.처리 중, 행렬을 사용하여 사각형 회전?
나는 이것이 사용법은 충분하다고 생각하지 않지만 heres는 회선을 회전시키는 코드이다.
float[][] rotation;
float[] position;
float theta = 180;
float pointX;
float pointY;
void setup() {
frameRate(60);
size(600, 600);
pointX = 0;
pointY = 0;
rotation = new float[2][2];
position = new float[8];
}
void draw() {
background(200);
theta = mouseX;
position[0] = mouseY;
position[1] = mouseY;
position[2] = -mouseY;
position[3] = mouseY;
rotation[0][0] = cos(radians(theta));
rotation[0][1] = -sin(radians(theta));
rotation[1][0] = sin(radians(theta));
rotation[1][1] = cos(radians(theta));
float newpos[] = new float[8];
newpos[0] += position[0] * rotation[0][0];
newpos[1] += position[1] * rotation[0][1];
translate(width/2, height/2);
line(0, 0, pointX+newpos[0], pointY+newpos[1]);
line(0, 0, pointX+newpos[0] * -1, pointY+newpos[1] * -1);
} pushMatrix()/popMatrix 살펴 갖는 의해
android.graphics.Matrix를 사용하지 않는 이유는 무엇입니까? – Michael
그 학교에 대한 선생님은 그것에 대해 아무것도 언급하지 않았다 .... 그리고 그는 우리가 지름길을 사용하는 것을 원하지 않는다. ... – Mark9135
Allright (비록 이것이 프로그래밍 과정이고 나는 선생님 이었다면 기존 클래스를 사용하는 대신 코드 작성에 대한 책임이 있음). 사각형 코드는 어디에 있습니까? – Michael