Jump to content
  • Advertisement
Sign in to follow this  
Samurai Jack

Angle between 3D matrices/points ?

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

Greetings! I would like to draw a bone (which is a mesh) between two joints (scene graph nodes). Each joint(node) has a relative and an absolute matrix which works as it should and it looks something like that:
R R R 0
R R R 0
R R R 0
X Y Z 1
- Where R represents a 3x3 rotation matrix derived from quaternion - Where X,Y,Z represent the translation of the matrix That is relative matrix and the absolute matrix is relative multiplied by the parent's absolute matrix. Is it very simple and straight forward. What I would like to do is to have a mesh something like a bone which would point to the child. So the bone would be drawn from the parent's absolute matrix (XYZ) but with different Rotation values pointing toward child. Ok, to simplify the problem. Scenario A) Let us take vector 1 (D3DXVECTOR3 v1=[x, y, z]) which represents the parent offset. And then vector 2 (D3DXVECTOR3 v2=[x, y, z]) which represents the child offset. So we would like bone pointing from V1 towards V2. How to solve it? With dot product? What I do not understand is that dotproduct returns a float. It is okay with D3DXVECTOR2 to get a float, because it is ONE angle between TWO dimensions, but we have 3 DIMENSIONS, wouldn't we need at least 2 angles in that case? Should I take arcus tangens 2 (v2-v1) to solve per component? Scenario B) We all know that the joint has a rotation matix. What happens If i would like also to rotate *TWIST* the bone like the rotation matrix [R..R] ? How to manage it? Is the simpliest way just to inverse the matrix? Does anyone have an idea how to sovle it? With scenario A solved, we can now rotate a bone from location V1 towars V2.

Share this post


Link to post
Share on other sites
Advertisement
When you look at a typical matrix for use in homogeneous coordinates is a rotation and translation component as you say. If you apply such a matrix to your basis vectors, (a vector representing a direction, not a location would have 0 in the 4th coordinate rather than 1)... then the basis vectors end up on the columns of the rotation part of the matrix... ie X-axis ends up on the first column, Y-axis on the second, Z-axis on the third. If you have a matrix representing the orientation of a bone relative to it's parent bone... Assuming your bones have a consistent bone axis (eg the local x, y or z axis points along the bone) you can simply draw your bone (or appopriate length) in local coordinates having applied the relative matrix. Clearly you have to traverse the "bone tree" applying the relative matrices cumulatively (poping/pushing as appropriate). In this way, no bone is required to know it's absolute origin... simply its length and relative position. Typically a translation will be applied locally so each bone has its root on the origin. I implemented a scheme exactly like this in a tree simulation I wrote, where a simply particle system (a driven damped oscillator) was applied based on external forces. The result was qualitatively realistic movement... and the tree was rendered with each "bone" being a spherically capped cylinder. The bones overlapped meaning the joint was not clearly visible (and the physics meant that large displacements typically only occured on narrow branches). I don't really understand what angle you are trying to obtain... The purpose of the orientation matrices for the bones is to orient the object to be rendered on them, meaning you shouldn't have to know any angles.
Anyway, I'm rambling again. Hope this helps,

Dan

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!