Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Let me say this up front: this problem is hard. There is a reason Dan Story's linked question has not been answered. Let provide an explanation for people who want to take a stab at it. I hope I'm wrong about how hard it is, though.</p> <p>I will assume that the 2D screen coordinates and projection/perspective matrix is known to you. You need to know at least this much (if you don't know the projection matrix, essentially you are using a different camera to look at the world). Let's call each pair of 2D screen coordinates <code>(a_i, b_i)</code>, and I will assume the projection matrix is of the form</p> <pre><code>P = [ px 0 0 0 ] [ 0 py 0 0 ] [ 0 0 pz pw] [ 0 0 s 0 ], s = +/-1 </code></pre> <p>Almost any reasonable projection has this form. Working through the rendering pipeline, you find that</p> <pre><code>a_i = px x_i / (s z_i) b_i = py y_i / (s z_i) </code></pre> <p>where <code>(x_i, y_i, z_i)</code> are the original 3D coordinates of the point.</p> <p>Now, let's assume you know your shape in a set of canonical coordinates (whatever you want), so that the vertices is <code>(x0_i, y0_i, z0_i)</code>. We can arrange these as columns of a matrix <code>C</code>. The actual coordinates of the shape are a rigid transformation of these coordinates. Let's similarly organize the actual coordinates as columns of a matrix <code>V</code>. Then these are related by</p> <pre><code>V = R C + v 1^T (*) </code></pre> <p>where <code>1^T</code> is a row vector of ones with the right length, <code>R</code> is an orthogonal rotation matrix of the rigid transformation, and <code>v</code> is the offset vector of the transformation.</p> <p>Now, you have an expression for each column of <code>V</code> from above: the first column is <code>{ s a_1 z_1 / px, s b_1 z_1 / py, z_1 }</code> and so on.</p> <p>You must solve the set of equations <code>(*)</code> for the set of scalars <code>z_i</code>, and the rigid transformation defined <code>R</code> and <code>v</code>.</p> <p><strong>Difficulties</strong></p> <ul> <li>The equation is nonlinear in the unknowns, involving quotients of <code>R</code> and <code>z_i</code></li> <li>We have assumed up to now that you know which 2D coordinates correspond to which vertices of the original shape (if your shape is a square, this is slightly less of a problem).</li> <li>We assume there is even a solution at all; if there are errors in the 2D data, then it's hard to say how well equation <code>(*)</code> will be satisfied; the transformation will be nonrigid or nonlinear.</li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload