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
Tracking Axis after Rotation
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
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
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.
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.
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
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
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);
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement