I did some math with orthographic projection matrix to compute viewing direction vectors in screen space.
I thought all viewing direction vectors should be parallel in orthographic projection because, in orthographic projection, eye sight lines will be always parallel.
However, the math doesn't show the parallel directions.
QMatrix4x4 proj;
proj.ortho(-100, 100, -100, 100, 1, 1001);
qDebug() << "projection matrix:" << proj;
auto inv = proj.inverted();
qDebug() << "inverse projection matrix:" << inv;
qDebug() << "viewing direction at bottom left corner:" << inv.map(QVector3D(-1, -1, 0)).normalized();
qDebug() << "viewing direction at top right corner :" << inv.map(QVector3D(1, 1, 0)).normalized();
This is small code to compute what I mentioned and the results are:
projection matrix: QMatrix4x4(type:Translation,Scale
0.01 0 0 0
0 0.01 0 0
0 0 -0.002 -1.002
0 0 0 1
)
inverse projection matrix: QMatrix4x4(type:Translation,Scale
100 0 0 0
0 100 0 0
0 0 -500 -501
0 0 0 1
)
viewing direction at bottom left corner: QVector3D(-0.192094, -0.192094, -0.962393)
viewing direction at top right corner : QVector3D(0.192094, 0.192094, -0.962393)
Here, viewing direction vectors at opposite corners don't look parallel.
Did I do something wrong here? Or, did I misunderstand orthographic projection? Why can't I get parallel rays here?