# Rotation of a 2D-Polygon

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

## Recommended Posts

Hi! I have some vertices which all have a Z - value of 0. That means that all vertices lie in the XY-plane. Furthermore, the first and the last vertex lie on the X-axis. Now I want to rotate the polygon around the x-axis. My qestion: How can I rotate the polygon? Is there a predefined method in DirectX that allows you to rotate a two-dimensional polygon or do I have to calculate all points myself? Thanks for your help :) Cheers, enne

##### Share on other sites
Well the thing is, your polygon isn't really 2D if it has a z-component even if you're setting it to zero and treating it as 2D, And once you rotate it around the x-axis, it really isn't going to be 2D since the z-components will no longer be 0. However this doesn't really matter, because since your polygon has to be ultimately displayed in 2D it's going to get "flattened" somehow once you apply some sort of projection matrix.

This means you should just use D3DXMatrixRotationX to generate an appropriate rotation matrix, and then just apply that. After that if you want the vertices to be "2D" again, you can either set the z-component to zero manually or just use an orthographic projection. Or, you can use a perspective projection and make it look "3D".

If you don't quite understand what I'm talking about I can explain further, but I would need to know a bit more about the specifics of your implementation.

##### Share on other sites
Quote:
 Original post by MJPWell the thing is, your polygon isn't really 2D if it has a z-component even if you're setting it to zero and treating it as 2D, And once you rotate it around the x-axis, it really isn't going to be 2D since the z-components will no longer be 0. However this doesn't really matter, because since your polygon has to be ultimately displayed in 2D it's going to get "flattened" somehow once you apply some sort of projection matrix. This means you should just use D3DXMatrixRotationX to generate an appropriate rotation matrix, and then just apply that. After that if you want the vertices to be "2D" again, you can either set the z-component to zero manually or just use an orthographic projection. Or, you can use a perspective projection and make it look "3D".If you don't quite understand what I'm talking about I can explain further, but I would need to know a bit more about the specifics of your implementation.

Sorry, I haven't explained very well what I want to do.
Actually I want to rotate my 2D-Polygon to get a rotational body. For example, if I draw a two-dimensional polygon like a rectangle, I want to rotate it to get a three-dimensional cylinder.

So I'll have a look at this D3DXMatrixRotationX.

Btw. my programming language is C# and I use DX9.

Again thx for your help :)

1. 1
2. 2
3. 3
4. 4
Rutin
12
5. 5

• 12
• 19
• 10
• 14
• 10
• ### Forum Statistics

• Total Topics
632665
• Total Posts
3007710
• ### Who's Online (See full list)

There are no registered users currently online

×