Closed xchhuang closed 5 years ago
Hi,
I have a question about the GLCamera::setupGL() function. Based on the source code, it returns a projection matrix using:
diag = sqrt(float(sqr(width) + sqr(height))); top = (float) height/diag * 0.5f*field_of_view * neardist; bottom = -top; right = (float) width/diag * 0.5f*field_of_view * neardist; left = -right; glFrustum(left, right, bottom, top, neardist, fardist)`.
However, the above calculation of (left, right, bottom, top) seems a bit different to what I have learned below (needs a tangent function):
function perspectiveCameraUsingFrustum (fovy, aspect, near, far) { top = near * Math.tan(toRadians(fovy)/2); bottom = -top; right = top * aspect; left = -right; return createFrustum(left, right, bottom, top, near, far); }
Can anyone explain if they are the same or their differences ? Thanks in advance.
It boils down to the same thing.
Hi,
I have a question about the GLCamera::setupGL() function. Based on the source code, it returns a projection matrix using:
However, the above calculation of (left, right, bottom, top) seems a bit different to what I have learned below (needs a tangent function):
Can anyone explain if they are the same or their differences ? Thanks in advance.