Jump to content
  • Advertisement
Sign in to follow this  
garusher

Tracking Axis after Rotation

This topic is 2954 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'm wondering if there is a standard solution for keeping track of your axis after rotation.

Here's an explanation. say i have a ray (0,0,0) to (0,23.5,0) and i apply (0,-90,0) rotation. my X axis actually becomes my Z axis

Now I thought maybe i could calculate the direction of my ray and somehow use this to determine my new axis direction.

Thanks
Gary Rusher

Share this post


Link to post
Share on other sites
Advertisement
Your ray doesn't have sufficient information to do that. Consider your example: you rotate a vector aligned with the Y axis about the Y axis. You end up with the same vector before and after rotation.

You can however, maintain a rotation matrix to which you apply all rotations before you apply them to the ray. Then, to determine the current orientation of any particular global axis in the ray's space, apply the rotation matrix to that axis.

vector x = (1,0,0) // global axis
vector local_x = matrixMultiply(x,rotationMatrix) // local space in global coords

Share this post


Link to post
Share on other sites
hi Buckeye,

This is my real issue.

I have box1, it's 23 long, 5 high and 0.75 thick

i apply rotation(0,-90,0)

now for box2 which is [initially the same size as box1] with the same rotation.

so after rotation i have two boxes basically sitting on each other.

now for box2, lets make box2 0.5 bigger in -X direction and 0.5 in -Y direction.

I want to know what direction i am expanding in.

Share this post


Link to post
Share on other sites
Hey,

I think you put me onto something.

I'll transform my point by rotation.
And transform my overlay value by rotation
Then add them together.

Thanks
Gary Rusher

Share this post


Link to post
Share on other sites
You shouldn't be modifying the box vertices themselves for the rotation. You can apply that only when you render it.

D3DXMATRIX boxWorld;
D3DXMatrixRotationY(&boxWorld, someAngleInRadians);
//.. to render
d3ddevice->SetTransform(D3DTS_WORLD,&boxWorld);
box->draw();
//...
box2.x -= 0.5f;
box2.y -= 0.5f;
// use same method above to draw the box
// if you want to know where the x-axis would appear when you render the box
D3DXVECTOR3 xaxis(1,0,0);
D3DXVec3TransformNormal(&xaxis,&xaxis,&boxWorld);


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!