0
$\begingroup$

In order to solve "this" problem, i have to transform my corner-points from a 2D Space to my 3D Space.

But my two coordinate fields are only defined by their relation to each other. They have the same distance-vector's relations. (i guess)

Is this even solvable?

enter image description here

$\endgroup$
0
+100
$\begingroup$

The simplest transformation between the two coordinate systems, and the one I suspect you’ve got in mind, is an affine map. It’s convenient to work in homogeneous coordinates, which allows this map to be represented by a $4\times3$ matrix $M$. I’ll use lower-case letters for points in the 2-D $u$-$v$ coordinate system and upper-case for points in the 3-D coordinate system to avoid ambiguity.

The constraints provided by the three point pairs can be captured in the “bulk” matrix equation $$M \begin{bmatrix}\mathbf p_1&\mathbf p_2&\mathbf p_3\\1&1&1\end{bmatrix}=\begin{bmatrix}\mathbf P_1&\mathbf P_2&\mathbf P_3\\1&1&1\end{bmatrix}$$ from which it immediately follows that $$M = \begin{bmatrix}\mathbf P_1&\mathbf P_2&\mathbf P_3\\1&1&1\end{bmatrix} \begin{bmatrix}\mathbf p_1&\mathbf p_2&\mathbf p_3\\1&1&1\end{bmatrix}^{-1}.$$ The inverse of the right-hand matrix exists as long as the three points are not colinear. (If they are, and the 3-D points are, too, there’s not a unique affine map, whereas if the 3-D points aren’t colinear, then there’s no affine map.) As a sanity check on your computation, the last row of $M$ should be $(0,0,1)$.†

The images of the corners of the 2-D unit square are then found by multiplying their homogeneous coordinate vectors by $M$, but the results will be simple combinations of the columns of $M$: $$(0,0) \mapsto M_3 \\ (1,0) \mapsto M_1+M_3 \\ (0,1) \mapsto M_2+M_3 \\ (1,1) \mapsto M_1+M_2+M_3.$$ You need to dehomogenize, of course, but if you’ve done this correctly, the last coordinate will always be $1$, so all you need to do to get the corresponding inhomogeneous Cartesian coordinates is to drop it.

† In fact, in practice you can drop the last row of $M$ so that you get dehomogenized coordinates directly when you multiply a homogeneous coordinate vector by $M$. If the last element of the homogeneous coordinate vector $\mathbf p$ is $1$, then so will be the last element of $M\mathbf p$, and dehomogenizing the result is a matter of dropping this $1$, as noted elsewhere.

$\endgroup$
  • $\begingroup$ I'm sorry, im a beginner and I am also only a programmer and not a mathematician. So I have a few noob-questions: 1. As far as I can tell you renamed: P1.x to P1 , P1.y to P2, P1.z to P3? And P1.u and P1.v to p1 and p2... What do you use instead of p3 ? since we dont have a third coordinate from our 2d dimension uv $\endgroup$ – OC_RaizW Feb 12 at 11:58
  • $\begingroup$ Do I fill it with Matrix.Identity values?? $\endgroup$ – OC_RaizW Feb 12 at 12:42
  • 1
    $\begingroup$ Nope. Each of the $p$’s is the entire 2- or 3-element coordinate vector of the point, written as a column vector per the usual mathematical convention. You’ll end up multiplying a $4\times3$ matrix by the inverse of a $3\times3$ matrix to compute $M$. $\endgroup$ – amd Feb 12 at 18:54
  • $\begingroup$ ohhh okay, that was my first mistake. Now ... I got M Next I need to Multiply the 3D VECTOR with the M matrix to get a 3D coordinate, right? So i multiply... lets say I want to know where my 2D point: 0.1/0.7 in the 3d World is... I multiply Vector3( 0.1, 0.7, ?? ) with M..? So.. there is the third digit missing.... right? $\endgroup$ – OC_RaizW Feb 13 at 11:11
  • $\begingroup$ And how do I dehomogenize something? I never dehomogenized anything in my life.... so... for stupid people.... dehomogenize means.... what? $\endgroup$ – OC_RaizW Feb 13 at 11:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.