Jump to content
• Advertisement

# Tracking Axis after Rotation

This topic is 3038 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

##### 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

##### 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

##### 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

##### 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 renderd3ddevice->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 boxD3DXVECTOR3 xaxis(1,0,0);D3DXVec3TransformNormal(&xaxis,&xaxis,&boxWorld);

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
2. 2
Rutin
22
3. 3
4. 4
khawk
14
5. 5
• Advertisement

• 13
• 26
• 10
• 11
• 44
• ### Forum Statistics

• Total Topics
633742
• Total Posts
3013639
×

## Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!