void MAIN(void) { Vector3D v(1 ,2 ,3); // from vector Vector3D w(0 , -1 , -4); // to vector double alpha ; Vector3D u; alpha = v.getAngle(w); // liefert winkel in rad u = v.cross (w).normalize(); AngleAxis u_phi(alpha, u); Quaternion q(u_phi); YPR ypr(q); PRINTF("Rotation q: "); q.print(); PRINTF("Rotation ypr: "); ypr.print(); PRINTF("----------- again --------------- \n"); q = Quaternion(cos(alpha/2), u.scale(sin(alpha/2))); ypr = YPR(q); PRINTF("Rotation q: "); q.print(); PRINTF("Rotation ypr: "); ypr.print(); }
void CObjectView::OnDraw(CDC* pDC) { SELECT_CONTEXT(); setupPerspective(); drawScene(&dList, tex); // turn off lighting glDisable(GL_LIGHTING); // draw tracker ball if ((mode == ROTATE || mode == LIGHT)&& GetCapture() == this){ // do overlay glEnable(GL_CULL_FACE); glClear(GL_DEPTH_BUFFER_BIT); glDisable(GL_STENCIL_TEST); // work out size of tracker float rad = 0.85f; // setup transform glMatrixMode(GL_MODELVIEW); if (mode == LIGHT) glLoadMatrixf(mL); else glLoadMatrixf(m); // mesh glPolygonMode(GL_FRONT, GL_LINE); glLineWidth(1); // draw light if (mode == LIGHT){ // get position Vector3D v = {1.0f, 1.0f, 1.0f}; v.norm(); v.scale(rad); // setup dot size GLint dotSize; glGetIntegerv(GL_POINT_SIZE, &dotSize); glPointSize(3); // draw light glColor3f(1.0f, 1.0f, 0.0f); glBegin(GL_POINTS); glVertex3f(v.x, v.y, v.z); glEnd(); glBegin(GL_LINES); glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(v.x, v.y, v.z); glEnd(); // restore dot size glPointSize(dotSize); } // draw sphere glColor3f(1, 0, 1); glRotatef(90, 1, 0, 0); GLUquadricObj *q = gluNewQuadric(); gluSphere(q, rad, 10, 10); gluDeleteQuadric(q); } // clean up and show picture glFlush(); SwapBuffers(hDC); UNSELECT_CONTEXT(); }