# D3DXMatrixLookAtLH

This topic is 4980 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 on other sites
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 on other sites

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_uspA x B = C (using the right handed rule)A x B = D (using the left handed rule)Where C = -D

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

1. 1
Rutin
42
2. 2
3. 3
4. 4
5. 5

• 18
• 20
• 14
• 14
• 9
• ### Forum Statistics

• Total Topics
633370
• Total Posts
3011544
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

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!