0
내 원을 그리는 다음 코드를 사용하고 있습니다 :OpenGL을 원 회전
double theta = 2 * 3.1415926/num_segments;
double c = Math.Cos(theta);//precalculate the sine and cosine
double s = Math.Sin(theta);
double t;
double x = r;//we start at angle = 0
double y = 0;
GL.glBegin(GL.GL_LINE_LOOP);
for(int ii = 0; ii < num_segments; ii++)
{
float first = (float)(x * scaleX + cx)/xyFactor;
float second = (float)(y * scaleY + cy)/xyFactor;
GL.glVertex2f(first, second); // output Vertex
//apply the rotation matrix
t = x;
x = c * x - s * y;
y = s * t + c * y;
}
GL.glEnd();
문제는 scaleX가이 scaleY를 다른 경우 다음 원은 회전을 제외하고 올바른 방법으로 변형된다는 것입니다. 내 코드 시퀀스에서 는 다음과 같습니다
circle.Scale(tmp_p.scaleX, tmp_p.scaleY);
circle.Rotate(tmp_p.rotateAngle);
내 질문은 scaleX가 및 scaleY가 동일하지 않을 때 내가 제대로 회전 원을 위해 수행해야하는 어떤 다른 계산인가? 내가이 녹색 선으로 늘어나는 것과해야 할 때 acctually
alt text http://www.freeimagehosting.net/uploads/c0cfc89146.gif
빨간색 선으로 늘어나는 것과 된 원이다.
회전 기능 :
double cosFi = Math.Cos(angle*Math.PI/180.0);
double sinFi = Math.Sin(angle * Math.PI/180.0);
double x, y;
double newX = 0, newY = 0;
DVector center = objectSize.CenterPoint;
y = ((MCircleCmd)cmdList[i]).m_Y;
x = ((MCircleCmd)cmdList[i]).m_X;
newX = (x - center.shiftX) * cosFi - (y - center.shiftY) * sinFi + center.shiftX;
newY = (x - center.shiftX) * sinFi + (y - center.shiftY) * cosFi + center.shiftY;
((MCircleCmd)cmdList[i]).m_X = newX;
((MCircleCmd)cmdList[i]).m_Y = newY;
UpdateSize(ref firstMove, newX, newY);
스케일 기능 :
public void Scale(double scale) // scale > 1 - increase; scale < 1 decrease
{
if (!isPrepared) return;
objectSize.x1 *= scale;
objectSize.x2 *= scale;
objectSize.y1 *= scale;
objectSize.y2 *= scale;
((MCircleCmd)cmdList[i]).m_X *= scale;
((MCircleCmd)cmdList[i]).m_Y *= scale;
((MCircleCmd)cmdList[i]).m_R *= scale;
((MCircleCmd)cmdList[i]).scaleX = scale;
((MCircleCmd)cmdList[i]).scaleY = scale;
}
크기 조정 및 회전 기능을 표시하지 않았습니다. Scale 함수는 scaleX/Y를 설정하지만 Rotate는 무엇을할까요? – Skizz
질문이 나에게 명확하지 않습니다. "원은 회전을 제외하고 올바른 방향으로 변형됩니다"라고 말합니다. 뭐가 잘못 됐어? 문제의 그림이 유용 할 것입니다. – tafa
문제의 이미지를 게시 할 수 있습니까? –