PDA

View Full Version : about perspective projection matrix

zydgyy
05-14-2012, 08:49 AM
here is from "http://www.opengl.org/sdk/docs/man/"

f=cotangent﻿(

fovy

2

)
The generated matrix is
(

f

aspect

f

zFar+zNear

zNear−zFar

2×zFar×zNear

zNear−zFar

-1

)

and here is my matrix in question:

const float w = d_area.getWidth();
const float h = d_area.getHeight();
const float aspect = w / h;
const float midx = w * 0.5f;
d_viewDistance = midx / (aspect * 0.267949192431123f);
const float nearZ = d_viewDistance * 0.5f;
const float farZ = d_viewDistance * 2.0f;
const float nr_sub_far = nearZ - farZ;
float tmp[4][4];
tmp[0][0] = 3.732050808f / aspect;
tmp[0][3] = -d_viewDistance;
tmp[1][1] = -3.732050808f;
tmp[1][3] = d_viewDistance;
tmp[2][2] = -((farZ + nearZ) / nr_sub_far);
tmp[3][2] = 1.0f;
tmp[3][3] = d_viewDistance;

So what does this matrix represent,orth,perspertive?

thokra
05-14-2012, 12:02 PM
Does an orthographic projection involve a field of view? You should find the answer in 3, 2, 1 ...

zydgyy
05-14-2012, 09:25 PM
Yes,there is no fovy,but i can't understand the matrix usage?!

thokra
05-15-2012, 12:02 AM
What exactly? Why we use matrices in the first place? How the matrices are derived? What a matrix is anyway?