finding vertex coordinates for rotated polygons

Started by
2 comments, last by Kalidor 19 years ago
Hi all, I was wondering if anyone could give me any hints as to how I could get the specific vertex coordinates for a polygon (in this case a 4-slice (square) cylinder) after rotation? If that is not possible, is it possible to apply a rotation to the coordinates in a vertex array (thereby giving me the same information as the previous problem). The problem is, I'm trying to write collision detection code for someone else's robotic arm simulator, and I need to do so fairly accurately, as I'm doing a work term for an engineering prof. The thing is, his simulator does not keep track of anything beyond the center points of the polygons that make up the robot, so I need to figure out how to find the vertices.
Advertisement
You could use rotation matricies. Set up a rotation matrix and then multiply it by every vertex coordinate before you plug it into the collision detector.

Heres a big FAQ on the subject ->
http://www.flipcode.com/documents/matrfaq.html
thanks! I had a sinking feeling I'd have to get my matrix-math on, so if that's how I've got to do it, that's cool.

However, I (just) saw a mention in this thread that it is possible to retrive data from the rotations with OGL, but with some performance issues. As the program I'm working on is fairly simple (one arm, at most a handful of objects in the environment to interact with), Im not too worried about speed of calculations. Does anyone know how to do what they were hinting at?
Quote:Original post by fearghaill
thanks! I had a sinking feeling I'd have to get my matrix-math on, so if that's how I've got to do it, that's cool.

However, I (just) saw a mention in this thread that it is possible to retrive data from the rotations with OGL, but with some performance issues. As the program I'm working on is fairly simple (one arm, at most a handful of objects in the environment to interact with), Im not too worried about speed of calculations. Does anyone know how to do what they were hinting at?


What was mentioned in that thread is just sending the transformation data to OpenGL (through glTranslatef/glRotatef/glScalef) and then using glGetFloatv() to retrieve it. All that does is let OpenGL calculate the transformation matrix for you and then return it in a float array. It's easy enough to calculate them yourself, and you will still need to multiply all the vertices with that matrix manually to get the transformed positions, so you might as well right some routines to get transformation matrices yourself as well. Plus it's good stuff to understand. [smile]

There's info all over the web about how to create different transformation matrices (including the link that Phy mentioned - link).

Good luck.

This topic is closed to new replies.

Advertisement