# problem with D3DXMatrixPerspectiveFovRH

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

## Recommended Posts

I was working out the math for D3DXMatrixPerspectiveFovRH and reached something I do not understand. using D3DXMatrixPerspectiveFovLH, and working out the math, transforming a point x,y,z,1 to a point x',y',z',w' we get: (1) z' = z * zf/(zf-zn) - zn*zf/(zf-zn) which is nice because setting z=zn -> z'=0 and setting z=zf -> z'=zf however, using D3DXMatrixPerspectiveFovRH (http://msdn.microsoft.com/en-us/library/bb205351(VS.85).aspx) I do not why zn*zf/(zn-zf) is not actually -zn*zf/(zn-zf) because again transforming a point with a RH matrix would give: (2) z' = z * zf/(zn-zf) + zn*zf/(zn-zf) what bothers me is the + instead of the - in (1) because this produces a non zero result when replacing z with zn. namely: z=zn -> z' = 2 * znzf / (zn - zf) and z=zf -> z' = (zfzf + znzf) / (zn - zf) can anyone comment on that?

##### Share on other sites
after thinking about it some more I think because it is an RH system, I need to set z=-zf and z=-zn to get the correct behavior, is that right?

##### Share on other sites
Yes D3DXMatrixPerspectiveFovLH assumes that the z value of the coordinate being projected is negative, and will produce a z value that is positive (since D3D natively uses a left-handed coordinate system)

##### Share on other sites
yes thats what I thought, I assume u mean D3DXMatrixPerspectiveFovRH though?

##### Share on other sites
Yes I meant RH, sorry. :P

1. 1
2. 2
Rutin
21
3. 3
4. 4
A4L
15
5. 5
khawk
14

• 13
• 26
• 10
• 11
• 44
• ### Forum Statistics

• Total Topics
633742
• Total Posts
3013630
×