내 Quaternion 구현에 문제가있는 것으로 보입니다. Download My quaternion implementation in Java.Quaternion "regular rotation"은 축 각도로 전환했을 때 값을 제공합니다.
나는이 조각을 미사일 때, main() 메소드에서, 사원 수 각도 진화시키기 위해서는 :
나는 다음과 같은 결과를 가지고Quaternion currentRotation = Quaternion.buildIdentityQuaternion();
Quaternion constantRotation = Quaternion.buildFromAxisAngle(10, 0,1,0);
while(true){
float angle = currentRotation.toAxisAngle()[0];
System.out.println(angle);
currentRotation = constantRotation.mulInLeftOf(currentRotation);
}
:
0.0
9.99997
19.999975
29.999979
39.99998
49.999977
59.999977
69.99998
79.99997
89.99997
99.99997
109.99997
119.99997
129.99997
139.99997
149.99997
159.99997
169.99997
179.99997
189.99998
199.99998
209.99998
219.99998
230.0
240.0
250.00002
260.00003
270.00003
280.00003
290.00006
300.0001
310.00012
320.00015
330.00024
340.00037
350.00082
360.0
350.00012
340.0001
330.0001
320.0001
310.00006
300.00006
290.00006
왜 수행을 각도 값은 먼저 360도에 도달 한 다음 0쪽으로 감소합니다. Quaternion # toAxisAngle() 메서드에서 2 * Acos (Quaternion.w)라는 공식을 사용하여 각도를 계산 했습니까? 어쩌면 구현이 나쁘지 않으므로 각도를 계산하여 0, 10, ..., 350, 360, 0, 10, ..., 350, 360, 0, 10 등의 각도를 계산할 수 있습니까?
마지막으로 실제 각도를 계산하는 방법이 있습니까? 0 °, 10 °, 30 °, ..., 360 °, 10 ° ... ... 값을 가로 지르는 각도
그러나 나는 단순히 사원 수의 곱셈마다 계산하여 그 결과 쿼터니언() 메소드 toMatrix를 호출하여 간단한 6 색 큐브, 정기적으로 회전 만들기 위해 JOGL 프로그램에서 사용할 수 있었다. (JOGL 특정 구현 세부 사항에주의를 지불하지 않습니다) 어떤 일 :
// The OpenGL functionnalities of my program
MyJOGLEventListener implements GLEventListener {
Quaternion myCurrentRotation = Quaternion.buildIdentityQuaternion() // w=1, x=0, y=0, z=0
Quaternion constantRotation = Quaternion.buildFromAxisAngle(0.02f, 0,1,0) // angle = 0.02 degrees, x=0, y=1, z=0
GLUgl2 glu = new GLUgl2();
public void display(GLAutoDrawable drawable) {
GL2 gl = drawable.getGL().getGL2();
gl.glClear(/* OMITTED : color buffer and depth buffer*/);
gl.glLoadIdentiy();
glu.gluLookAt(/* OMITTED */);
/// the three most relevent lines ///////////////////////////////////
gl.glMultMatrix(myCurrentRotation.toMatrix(), 0);
MyCubeDrawer.drawCube(gl);
myCurrentRotation = constantRotation.mulInLeftOf(myCurrentRotation);
//////////////////////////////////////////////////////////////////////
}
// OMITED : in init(GLAutoDrawable) method, I set up depth buffer
// OMITED : the reshape(GLAutoDrawable drawable, int x, int y, int width, int height) sets the viewport and projection
}
감사
대단히 감사합니다 ^^ 귀하의 팁은 아마도 최고 중 하나 (아마도 최고는 아니지만)이지만, 마침내 클라이언트 클래스에 인스턴스 변수를 추가하여 내 문제를 "해결"하여 쿼터니언을 각도로 변환합니다. – loloof64