Reputation: 619
Almost all the theoretical stuff I read about projection matrices have the first element being 2n/(r-l)
, but most of the open source implementations I've seen have it as 2n/((t-b)*a)
, -- which makes sense to me at first since (r-l)
should be ((t-b)*a)
, but when I actually run the numbers, something feels off.
If we have a vertical field of view of 65 degrees, a near plane of .1, and an aspect ratio of 4:3, then I seem to get:
2n/(r-l) = .2 / (tan(65*(4/3)*.5) * .2) = 1.0599
but
2n((t-b)*a) = .2 / (tan(65*.5) * (4/3) * .2) = 1.1773
Why is there a difference between everything I read, and everything I see implemented? I didn't notice until I started implementing the same analytical inverse I see whose first element is (r-l)/2n, which isn't the inverse of these other implementations.
Upvotes: 0
Views: 77
Reputation: 45332
You can't multiply the aspect ratio into the angle. The tangens isn't a linear function. Having 65 degress vertical field of view does not mean that you're going to have 86,67 degrees horizontal FOV with 4:3 aspect, but ~80.69 degrees.
Upvotes: 1