• Advertisement
Sign in to follow this  

problem with D3DXMatrixPerspectiveFovRH

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

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement