1

The program rotates a point using the glRotatef function, how can I calculate the coordinates of the point after the rotation, or is there a function in PyOpenGL to do this?

def drawPoint():

   glBegin(GL_POINTS)
   glVertex(1,0,0)
   glEnd()

def DrawGL():

   glRotatef(mymiu.Yaw, 0, -1, 0)
   glRotatef(mymiu.Pitch, 0, 0, 1)
   glRotatef(mymiu.Roll, -1, 0, 0)

   drawPoint()

the code is reduced to the essentials

How do i get the position of the Point after the Rotation?

  • 1
    Why do you need the coordinates of the vertex? While you can get them from OpenGL, this is not the best library to do math with if that's what you are doing. You would be better off using numpy to do the matrix multiplication. – Code-Apprentice Apr 04 '22 at 14:59
  • I need the vertex coordinates to plot them. Unfortunately, I have very little experience with matrix multiplication. How can I do this in Python to get the position of the point depending on the rotation? – JohannesDev Apr 04 '22 at 15:16
  • "I need the vertex coordinates to plot them." Let OpenGL do that for you. The entire purpose of OpenGL is to render graphics for you. – Code-Apprentice Apr 04 '22 at 15:27
  • OpenGL is a complex graphics library. It might not be the best tool for the job. You should research other libraries that might also fit your use case. For example, matplotlib is a great drawing library. It's still complex, but much higher level than OpenGL, so it might fit your needs better. – Code-Apprentice Apr 04 '22 at 15:29
  • If you still decide to continue with OpenGL, you should find an up-to-date tutorial. Functions like `glVertex` and `glRotate` are from Open GL 2.x. Version 3.x and later uses what are called "shaders" instead. You should spend your time learning current technology rather than struggling with the old way of doing things. – Code-Apprentice Apr 04 '22 at 15:30
  • Ignoring the OpenGL 3 and performance stuff - you can get the matrix (glGetMatrix) and then do the math yourself. One reason that functions like glRotatef were removed from OpenGL is that programmers often had to use their own math libraries anyway, so having an extra copy in OpenGL was silly. – user253751 Apr 04 '22 at 16:04
  • [`GL_FEEDBACK`](http://www.glprogramming.com/red/chapter13.html#name2), though that's old, probably slow, and possibly busted. – genpfault Apr 04 '22 at 16:09

0 Answers0