Sign in to follow this  

Rotation of a 2D-Polygon

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by MJP
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.


Thanks for your answer.
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 :)

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this