problem with D3DXMatrixPerspectiveFovRH

Started by
3 comments, last by MJP 15 years, 3 months ago
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?
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?
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)
yes thats what I thought, I assume u mean D3DXMatrixPerspectiveFovRH though?
Yes I meant RH, sorry. :P

This topic is closed to new replies.

Advertisement