Jump to content

  • Log In with Google      Sign In   
  • Create Account


3D math problem


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 promo   Members   -  Reputation: 122

Like
Likes
Like

Posted 25 September 2001 - 05:12 AM

Hi people. I have the following problem: Imagine a starship looking straight ahead. straight is into the Z axis, up is the Y. If I wanted to turn the ship left or right I would rotate it around the Y axis. OK. Now if this ship would be facing up towards the Y axis, turning left/right would mean rotating along the Z. And if it was in between.... I know I can find the vector to rotate around using simple transformation matrices, but does anyone know how I get the new angles I need? All my 3D objects have absolute (to the axes) angles. How do I know which angles to change when I want the ship "up 3 degrees" or "left 5 degrees"? Thanx in advance! -------------------- so, what you''''re saying is, that the mushroom spores were brought in from outer space by - who?? -cosmosis

Sponsor:

#2 Ace17   Members   -  Reputation: 122

Like
Likes
Like

Posted 25 September 2001 - 05:17 AM

I''ve been confronted to the same problem
You should have a look to C Hecker Tutorials
My Math knowledge doesn''t permitt me to explain you, but
there you should find what you need :
http://www.d6.com/users/checker/dynamics.htm
I Hope you''re motivated cause it''s kinda pretty hard stuff

#3 Ace17   Members   -  Reputation: 122

Like
Likes
Like

Posted 25 September 2001 - 05:21 AM

Another usefull info
You should read the whole 4 tutz on rigid body dynamics, but
the tutorial you need is the 4th

#4 blackbot20   Members   -  Reputation: 118

Like
Likes
Like

Posted 25 September 2001 - 02:55 PM

This might help...

Keep track of the current up, look, and right vectors of the ship. When you need to pitch up rotate by these axis.

Be sure to normalize and true these axises by each other after rotating them, by doing something like this:

// cross product of Up and Look vectors
m_vRight = GVector3CrossProduct(m_vUp, m_vLook);
m_vRight = GVector3Normalize(m_vRight);

// cross product of Look and Right vectors
m_vUp = GVector3CrossProduct(m_vLook, m_vRight);
m_vUp = GVector3Normalize(m_vUp);



You can get the full transform to align the ships vectors with the world space by the following:

// Right to x axis
matTransform._11 = m_vRight.x;
matTransform._21 = m_vRight.y;
matTransform._31 = m_vRight.z;
matTransform._41 = 0;

// Up to y axis
matTransform._12 = m_vUp.x;
matTransform._22 = m_vUp.y;
matTransform._32 = m_vUp.z;
matTransform._42 = 0;

// Look to z axis
matTransform._13 = m_vLook.x;
matTransform._23 = m_vLook.y;
matTransform._33 = m_vLook.z;
matTransform._43 = 0;

// complete the matrix
matTransform._14 = 0;
matTransform._24 = 0;
matTransform._34 = 0;
matTransform._44 = 1;


So the whole thing would go like this:
1. Do the above transform to the axises to temporally align the ship with the world axises.
2. Rotate the axises as you would normally do.
3. Use the transpose matrix of the first matrix transform to get back to actual world coordinates for the axises.
4. Do this for each axis. Then normalize and true the axises.

To display the ship or view from the ship apply the transpose of the above transform (using the current ship’s vectors to calculate the transform).







Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS