<p>You only transferred a single point from projection space to view space.</p>
<p>But you are interested in directions, so you need to convert two points to be able to see the view direction.</p>
<pre><code>//check view direction of lower left corner 
vec4 p0_0 = vec4(-1,-1,0,1);
vec4 p0_1 = vec4(-1,-1,1,1);

//check view direction of upper right corner
vec4 p1_0 = vec4(1,1,0,1);
vec4 p1_1 = vec4(1,1,1,1);

Vec4 ip0_0 = inverprojection * p0_0
Vec4 ip0_1 = inverprojection * p0_1
Vec4 ip1_0 = inverprojection * p1_0
Vec4 ip1_1 = inverprojection * p1_1
</code></pre>
<p>So we have two points per view direction test.</p>
<pre><code>Vec4 viewDir0 = ip0_0 - ip0_1
Vec4 viewDir1 = ip1_0 - ip1_1
</code></pre>
<p>Last step is to compare viewDir0 with viewDir1</p>

CC BY-SA 4.0
2023-12-01T17:23:23.230Z
You can do exactly the same with perspective projections... But then you need to divide the outcomming vectors by their 4th component...
Thomas
CC BY-SA 4.0
2023-12-01T17:19:09.010Z
2023-12-01T17:19:09.010Z
Thomas
<p>I did some math with orthographic projection matrix to compute viewing direction vectors in screen space.</p>
<p>I thought all viewing direction vectors should be parallel in orthographic projection because, in orthographic projection, eye sight lines will be always parallel.</p>
<p>However, the math doesn't show the parallel directions.</p>
<pre class="lang-cpp prettyprint-override"><code>    QMatrix4x4 proj;
    proj.ortho(-100, 100, -100, 100, 1, 1001);
    qDebug() &lt;&lt; &quot;projection matrix:&quot; &lt;&lt; proj;
    auto inv = proj.inverted();
    qDebug() &lt;&lt; &quot;inverse projection matrix:&quot; &lt;&lt; inv;
    qDebug() &lt;&lt; &quot;viewing direction at bottom left corner:&quot; &lt;&lt; inv.map(QVector3D(-1, -1, 0)).normalized();
    qDebug() &lt;&lt; &quot;viewing direction at top right corner  :&quot; &lt;&lt; inv.map(QVector3D(1, 1, 0)).normalized();
</code></pre>
<p>This is small code to compute what I mentioned and the results are:</p>
<pre><code>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)
</code></pre>
<p>Here, viewing direction vectors at opposite corners don't look parallel.</p>
<p>Did I do something wrong here? Or, did I misunderstand orthographic projection?
Why can't I get parallel rays here?</p>

<projections>
viewing direction vectors are not parallel in orthographic projection
slyx
# viewing direction vectors are not parallel in orthographic projection

(Asked by: username_0 on 2023-12-01)

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?

**Tags:** projections

---

## 1 answers

### Answer by username_1 on 2023-12-01. Score: 1 | Accepted answer

You only transferred a single point from projection space to view space.
But you are interested in directions, so you need to convert two points to be able to see the view direction.
//check view direction of lower left corner 
vec4 p0_0 = vec4(-1,-1,0,1);
vec4 p0_1 = vec4(-1,-1,1,1);

//check view direction of upper right corner
vec4 p1_0 = vec4(1,1,0,1);
vec4 p1_1 = vec4(1,1,1,1);

Vec4 ip0_0 = inverprojection * p0_0
Vec4 ip0_1 = inverprojection * p0_1
Vec4 ip1_0 = inverprojection * p1_0
Vec4 ip1_1 = inverprojection * p1_1

So we have two points per view direction test.
Vec4 viewDir0 = ip0_0 - ip0_1
Vec4 viewDir1 = ip1_0 - ip1_1

Last step is to compare viewDir0 with viewDir1

> **Comments:**
> **username_1**: You can do exactly the same with perspective projections... But then you need to divide the outcomming vectors by their 4th component...  

---

