Jump to content
  • Advertisement
Sign in to follow this  
TAO

D3DXMatrixLookAtLH

This topic is 4891 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 am a little bit confused at the term D3DXMatrixLookAtLH and D3DXMatrixLookAtRH. According to the documentation for lh zaxis = normal(At - Eye) xaxis = normal(cross(Up, zaxis)) yaxis = cross(zaxis, xaxis) for rh zaxis = normal(Eye - At) xaxis = normal(cross(Up, zaxis)) yaxis = cross(zaxis, xaxis) both coordinates constructured will satisfy x cross y = z, y cross z = x and z cross x = y. then what is the real meaning of Left hand and righ hand?

Share this post


Link to post
Share on other sites
Advertisement
The difference between the left-handed and right-handed coordinate systems is the z-axis' direction (they are opposed).

The cross product's definition depends on the kind of the coordinate system. That is, once you define a coordinate system based on a rule (left or right hand), every cross product in this space must be applied using the same rule.



So, considering two vectors A and B:

A x B = C (using the right hand rule)
A x B = D (using the left hand rule)

Where C = -D

Share this post


Link to post
Share on other sites
Adriano, Hi:

Thanks for your reply. I know the definitions LH and RH coordinate system. What I don't understand is the differences of matrices generated by D3DXMatrixLookAtLH and D3DXMatrixLookAtRH. They all fit the definition of right hand CS. Therefore, why do we have two functions?


Quote:
Original post by adriano_usp

A x B = C (using the right handed rule)
A x B = D (using the left handed rule)

Where C = -D

Share this post


Link to post
Share on other sites
I'm not sure if I understood your doubt...

Quote:
What I don't understand is the differences of matrices generated by D3DXMatrixLookAtLH and D3DXMatrixLookAtRH

The elements from these matrices are not different. Both have the same layout:

xaxis.x yaxis.x zaxis.x 0
xaxis.y yaxis.y zaxis.y 0
xaxis.z yaxis.z zaxis.z 0
-dot(xaxis, eye) -dot(yaxis, eye) -dot(zaxis, eye) 1

What is different is the z-axis direction. This affects the content of the matrices (creating matrices a little different).

Quote:
Therefore, why do we have two functions?

Well, a same vector can be expressed relative to different coordinate systems. The matrix generated by D3DXMatrixLookAtLH or D3DXMatrixLookAtRH is just a math entity that transforms vectors from the world space to the view space.
The world coordinate system from Direct3D is based on the left hand rule. So, it is a free choice to use a right-handed coordinate system (by applying D3DXMatrixLookAtRH) or a left-handed coordinate system (by applying D3DXMatrixLookAtLH) to define the view space. I usually use D3DXMatrixLookAtLH.

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!