#### Archived

This topic is now archived and is closed to further replies.

# Rotating....how does it work?

This topic is 5759 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Wow, i guess nobody understands collision detection, lol. I have another question that might be easier to answer (no, I don't know the answer), how does glRotatef work? If I have four points: -5.0f,-2.4f 5.0f,-2.4f 5.0f, 2.4f -5.0f, 2.4f and I rotate them 34 degrees on the z plane, what will be the new coordinates of the four points? I want to be able to find this out without having to use glRotate, so that I can use it in my collision detection (collision of a line and poly). hopefully someone out there knows how it works, and if you do, please give me an example, don't just say something like, normalize vector p so it equals xv+yv+zv and then square that by the base polynomial.......and etc.. -jverkoey [edited by - jverkoey on February 6, 2003 9:43:31 PM]

##### Share on other sites
It is an axis-angle rotation. Picture a 2D rotation around the origin. If you draw a circle centered at the origin through the point being rotated then the point after rotation will be on the circle as well. The exact same thing in 3D is a rotation of a point in the xy plane around the z-axis. Within 3D it doesn''t have to be the z-axis though the axis still goes through the origin. So it is as though you picked up your graph paper and tilted it.

##### Share on other sites
ok...but the thing is, I want to be able to tell what the new coordinates ARE after the rotation

##### Share on other sites
glRotatef is simply a 4x4 (or 3x3 if 2D scene) matrix that performs the rotation transformation. If you want to know the coordinates after rotation I suggest you look at 3D matrix transformations, cos basically all you have to do is multiply each point you have with the matrix and you''ll have the new coordinates.

##### Share on other sites
eeeerrrrrggggg, i guess no one''s understanding me, lol. What I want to know, is an example of how it works....say I had the 4 points above, and I wanted to rotate it all by 32 degrees, HOW would i do that?

-jverkoey

##### Share on other sites
Pseudo:

// translate to center of figure (by subtracting the point from the average of the points)

POINT Start, End, New;
Start = <-5, -2.4>;

End = New; // this contains the new value

Angles must be in radians. The figure radius is the average distance of points from the center.

or something like that. Just look up "2D rotation" on google for the forumlas; this is a pretty well documented subject.

Sorry if the above is wrong; it's been a long time since I did that stuff manually.

Later,
ZE.

//email me.//zealouselixir software.//msdn.//n00biez.//

[edited by - zealouselixir on February 7, 2003 5:40:21 PM]

##### Share on other sites
thank you ZealousElixir, that helps a lot! Now I can finally start working on my collision detection!

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633302
• Total Posts
3011272
• ### Who's Online (See full list)

There are no registered users currently online

×