2
$\begingroup$

I multiply a 4 x 4 matrix by a 4 component vector, and I'm trying to find the value of the z component working backwards. The following picture is just to show you what I'm talking about.

enter image description here

After doing this multiplication then z is divided by w, which as you can see always ends up being negative z. Before multiplying the w component is ALWAYS 1.

The final result I get we'll call "d". Now I try to write an equation which shows this, and I get:

enter image description here

Then I simplify this to:

enter image description here

I would like to know if this is solvable for z. Every time I try I end up getting something like z over z on one side. I'm not good at math at all, this is my attempt:

First simplify a little:

enter image description here

Multiply both sides by "f - n"

enter image description here

There are many different different ways I've tried it, in one case I got a solution which was:

enter image description here

But it didn't work out. I mean the image didn't display the correct depth value. I'd appreciate any help.

$\endgroup$

1 Answer 1

1
$\begingroup$

The correct solution is $$z = {2fn \over \color{red}{(f-n)d-(f+n)}}.$$ Whatever error you’re making occurs after the last step that you showed. Unfortunately, you don’t show any of your work after that, so I can only guess at what that mistake might have been. Perhaps you made a simple sign error. Anyway, starting from where you left off, a correct solution might proceed as follows: $$\begin{align} -(f-n)dz &= -(f+n)z - 2fn \\ (f-n)dz-(f+n)z &= 2fn \\ \left((f-n)d -(f+n)\right) z &= 2fn \\ z &= {2fn \over (f-n)d-(f+n)} . \end{align}$$ To check this solution, substitute this expression for the original $z$-coordinate of the point, apply the projection and simplify. You should end up with $d$.

$\endgroup$
2
  • $\begingroup$ Thank you so much. I also got the answer z = -2fn over (f + n) - d(f - n) and it also works. Any intuitive clue you can give on why they're the same? $\endgroup$
    – Zebrafish
    Commented Oct 24, 2017 at 1:44
  • $\begingroup$ Never mind, it's obvious. Thanks so much. $\endgroup$
    – Zebrafish
    Commented Oct 24, 2017 at 1:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .