현재 산점도에 대한 산점도를 원점을 기준으로 회전하려고합니다. 이전 게시물에 이어 다음 두 방정식 세트를 사용하고 있습니다. https://en.wikipedia.org/wiki/Transformation_matrix문제 직교 좌표계에서 X, Y 좌표를 회전
참고 :이 게시물은 방정식의 구현이 작동하지 않는 방법을 다루었 기 때문에 이전 게시물과 다릅니다.
그러나 방정식을 적용한 후에는 원점을 기준으로 전혀 회전하지 않습니다. 그것을 해결하는 방법에
//Loop through all points
for (int playerEntity = 0; playerEntity < 13; playerEntity++) {
//x and y coords for point
int px;
int py;
//If rotation angle requires counter clockwise (- degree) rotation
if (theta< 0) {
//Load point from scatter plot relative to origin
px = positionX[playerEntity]/20;
py = positionY[playerEntity]/20;
//Convert the degree rotation to radians
double rad = (theta*3.1415)/180;
//Apply Counter Clockwise rotation equations
px = px * cos(rad) - py * sin(rad);
py = py * cos(rad) + px * sin(rad);
}
else {
//Load point from scatter plot relative to origin
px = positionX[playerEntity]/20;
py = positionY[playerEntity]/20;
//Convert the degree rotation to radians
double rad = (theta*3.1415)/180;
//Apply Clockwise rotation equations
px = px * cos(rad) + py * sin(rad);
py = py * cos(rad) - px * sin(rad);
}
//Define origin
int originX = 1000;
int originY = 500;
//Graph points (Note it subtracts py, as negative y values make it plot upwards and positive y values make it plot downwards
colorPixel(originX + px , originY- py);
}
어떤 아이디어 : 여기
내 현재 코드인가? 당신이 이미 변형 px
을 사용하는 새로운 py
을 계산할 때
답이 있었지만 방정식을 구현했을 때 작동하지 않았습니다. – user3341249
"py = py * cos (rad) - px * sin (rad)"행은 px의 * previous * 값이 필요합니다. 하나는 바로 전에 바뀌 었습니다. 매개 변수 px2, py2를 입력하고 수식을 사용하여 계산 한 다음 px, py에 복사해야합니다 (현재 상태에서는 특정 의미로 앉아있는 지점을 톱질합니다). – BrunoLevy
예. 감사합니다. 당신의 대답을 위해! 그것은 정확하게 내가해야 할 일이었습니다. 나는 오류를 찾을 때 고려조차하지 않았습니다. – user3341249