Transformation matrix between a 2D and a 3D coordinate system
up vote
0
down vote
favorite
Supposing I have this data :
2D points (known coordinates): P2D
in a 2D coordinate system CS2D
. and their corresponding (their equivalent)
3D points (known coordinates) : P3D
. in a 2D coordinate system CS3D
.
PS : CS2D
& CS3D
don't have the same origin.
How would I find a transformation matrix T
(Rotation, Translation, Scaling) such as it allows to go from any 3D point to it's correspondent 2D point or the inverse ? Some kind of : P2D = T * P3D
How would I approach this problem ?
linear-algebra transformation projection
add a comment |
up vote
0
down vote
favorite
Supposing I have this data :
2D points (known coordinates): P2D
in a 2D coordinate system CS2D
. and their corresponding (their equivalent)
3D points (known coordinates) : P3D
. in a 2D coordinate system CS3D
.
PS : CS2D
& CS3D
don't have the same origin.
How would I find a transformation matrix T
(Rotation, Translation, Scaling) such as it allows to go from any 3D point to it's correspondent 2D point or the inverse ? Some kind of : P2D = T * P3D
How would I approach this problem ?
linear-algebra transformation projection
1
Sorry I don't understand what are you saying, I'm not a computer scientist.
– P De Donato
Nov 21 at 14:14
1
You're not going to be able to get an invertable linear transformation since the dimensions don't match. What you probably want is a projection. en.wikipedia.org/wiki/Projection_(linear_algebra)
– Wintermute
Nov 21 at 14:14
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Supposing I have this data :
2D points (known coordinates): P2D
in a 2D coordinate system CS2D
. and their corresponding (their equivalent)
3D points (known coordinates) : P3D
. in a 2D coordinate system CS3D
.
PS : CS2D
& CS3D
don't have the same origin.
How would I find a transformation matrix T
(Rotation, Translation, Scaling) such as it allows to go from any 3D point to it's correspondent 2D point or the inverse ? Some kind of : P2D = T * P3D
How would I approach this problem ?
linear-algebra transformation projection
Supposing I have this data :
2D points (known coordinates): P2D
in a 2D coordinate system CS2D
. and their corresponding (their equivalent)
3D points (known coordinates) : P3D
. in a 2D coordinate system CS3D
.
PS : CS2D
& CS3D
don't have the same origin.
How would I find a transformation matrix T
(Rotation, Translation, Scaling) such as it allows to go from any 3D point to it's correspondent 2D point or the inverse ? Some kind of : P2D = T * P3D
How would I approach this problem ?
linear-algebra transformation projection
linear-algebra transformation projection
edited Nov 22 at 10:11
asked Nov 21 at 13:39
Calips
1013
1013
1
Sorry I don't understand what are you saying, I'm not a computer scientist.
– P De Donato
Nov 21 at 14:14
1
You're not going to be able to get an invertable linear transformation since the dimensions don't match. What you probably want is a projection. en.wikipedia.org/wiki/Projection_(linear_algebra)
– Wintermute
Nov 21 at 14:14
add a comment |
1
Sorry I don't understand what are you saying, I'm not a computer scientist.
– P De Donato
Nov 21 at 14:14
1
You're not going to be able to get an invertable linear transformation since the dimensions don't match. What you probably want is a projection. en.wikipedia.org/wiki/Projection_(linear_algebra)
– Wintermute
Nov 21 at 14:14
1
1
Sorry I don't understand what are you saying, I'm not a computer scientist.
– P De Donato
Nov 21 at 14:14
Sorry I don't understand what are you saying, I'm not a computer scientist.
– P De Donato
Nov 21 at 14:14
1
1
You're not going to be able to get an invertable linear transformation since the dimensions don't match. What you probably want is a projection. en.wikipedia.org/wiki/Projection_(linear_algebra)
– Wintermute
Nov 21 at 14:14
You're not going to be able to get an invertable linear transformation since the dimensions don't match. What you probably want is a projection. en.wikipedia.org/wiki/Projection_(linear_algebra)
– Wintermute
Nov 21 at 14:14
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Since this is a math site, I'll answer this in a mathematical format.
It will probably translate relatively directly to whatever software library
you are currently using.
The first step is to identify the 3D coordinates of the following points:
$mathbf p_0,$ the point that has coordinates $(0,0)$ according to the 2D coordinate system;
$mathbf p_1,$ the point that has coordinates $(1,0)$ according to the 2D coordinate system;
$mathbf p_2,$ the point that has coordinates $(0,1)$ according to the 2D coordinate system.
That is, the three points $mathbf p_0,$ $mathbf p_1,$ and $mathbf p_2,$
which describe the origin of the 2D coordinates and points on the two axes of the 2D coordinates, have 3D coordinates that could be written as column vectors like this:
$$
mathbf p_0 = begin{pmatrix} p_{01} \ p_{02} \ p_{03} end{pmatrix},quad
mathbf p_1 = begin{pmatrix} p_{11} \ p_{12} \ p_{13} end{pmatrix},quad
mathbf p_2 = begin{pmatrix} p_{21} \ p_{22} \ p_{23} end{pmatrix}.
$$
From these points we can derive two vectors:
$mathbf e_1 = mathbf p_1 - mathbf p_0$
and $mathbf e_2 = mathbf p_2 - mathbf p_0,$
where the subtraction is a componentwise vector operation.
Now to translate any 2D coordinates $(x,y)$ into 3D coordinates, you perform scalar multiplication (scaling) and componentwise addition of these vectors to produce a 3D point $mathbf p$:
$$ mathbf p = mathbf p_0 + x mathbf e_1 + y mathbf e_2. $$
(That is, $xmathbf e_1$ multiplies each coordinate of $mathbf e_1$ by $x,$
and so forth.)
If your library supports matrices and matrix multiplication (which seems likely),
you can put the coordinates of $mathbf e_1$ and $mathbf e_2$ side by side in two columns within a matrix,
and then for any 2D coordinates $(x,y)$ peform the following matrix multiplication,
which produces a $3$-element column vector:
$$
mathbf p =
mathbf p_0 +
begin{pmatrix} e_{11} & e_{21} \ e_{12} & e_{22} \ e_{13} & e_{23} end{pmatrix}
begin{pmatrix} x \ y end{pmatrix}
$$
And that is how you convert any 2D coordinates to 3D.
To convert in the opposite direction, from 3D to 2D, I'll assume you want orthogonal projection, that is, you want to map each point in the 3D space to the closest point in the 2D plane.
You do this with the same vectors $mathbf e_1$ and $mathbf e_2$ that you used for the 2D-to-3D transformation,
as well as the 3D coordinates $mathbf p_0$ of the origin of the 2D system.
Given a point in 3D coordinates, expressed as a column vector $mathbf p,$
take the following dot products (aka inner products):
begin{align}
x &= (mathbf p - mathbf p_0) cdot mathbf e_1, \
y &= (mathbf p - mathbf p_0) cdot mathbf e_2.
end{align}
Then $(x,y)$ are the desired 2D coordinates.
Depending on your library, it might not have an explicit dot product operation
but might allow you to transpose a vector instead, in which case you can use matrix multiplication on the "vectors" in order to compute the dot products, for example,
using the superscript $T$ to indicate a transpose, as in $mathbf v^T,$
$$
x = (mathbf p - mathbf p_0)^T mathbf e_1.
$$
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Since this is a math site, I'll answer this in a mathematical format.
It will probably translate relatively directly to whatever software library
you are currently using.
The first step is to identify the 3D coordinates of the following points:
$mathbf p_0,$ the point that has coordinates $(0,0)$ according to the 2D coordinate system;
$mathbf p_1,$ the point that has coordinates $(1,0)$ according to the 2D coordinate system;
$mathbf p_2,$ the point that has coordinates $(0,1)$ according to the 2D coordinate system.
That is, the three points $mathbf p_0,$ $mathbf p_1,$ and $mathbf p_2,$
which describe the origin of the 2D coordinates and points on the two axes of the 2D coordinates, have 3D coordinates that could be written as column vectors like this:
$$
mathbf p_0 = begin{pmatrix} p_{01} \ p_{02} \ p_{03} end{pmatrix},quad
mathbf p_1 = begin{pmatrix} p_{11} \ p_{12} \ p_{13} end{pmatrix},quad
mathbf p_2 = begin{pmatrix} p_{21} \ p_{22} \ p_{23} end{pmatrix}.
$$
From these points we can derive two vectors:
$mathbf e_1 = mathbf p_1 - mathbf p_0$
and $mathbf e_2 = mathbf p_2 - mathbf p_0,$
where the subtraction is a componentwise vector operation.
Now to translate any 2D coordinates $(x,y)$ into 3D coordinates, you perform scalar multiplication (scaling) and componentwise addition of these vectors to produce a 3D point $mathbf p$:
$$ mathbf p = mathbf p_0 + x mathbf e_1 + y mathbf e_2. $$
(That is, $xmathbf e_1$ multiplies each coordinate of $mathbf e_1$ by $x,$
and so forth.)
If your library supports matrices and matrix multiplication (which seems likely),
you can put the coordinates of $mathbf e_1$ and $mathbf e_2$ side by side in two columns within a matrix,
and then for any 2D coordinates $(x,y)$ peform the following matrix multiplication,
which produces a $3$-element column vector:
$$
mathbf p =
mathbf p_0 +
begin{pmatrix} e_{11} & e_{21} \ e_{12} & e_{22} \ e_{13} & e_{23} end{pmatrix}
begin{pmatrix} x \ y end{pmatrix}
$$
And that is how you convert any 2D coordinates to 3D.
To convert in the opposite direction, from 3D to 2D, I'll assume you want orthogonal projection, that is, you want to map each point in the 3D space to the closest point in the 2D plane.
You do this with the same vectors $mathbf e_1$ and $mathbf e_2$ that you used for the 2D-to-3D transformation,
as well as the 3D coordinates $mathbf p_0$ of the origin of the 2D system.
Given a point in 3D coordinates, expressed as a column vector $mathbf p,$
take the following dot products (aka inner products):
begin{align}
x &= (mathbf p - mathbf p_0) cdot mathbf e_1, \
y &= (mathbf p - mathbf p_0) cdot mathbf e_2.
end{align}
Then $(x,y)$ are the desired 2D coordinates.
Depending on your library, it might not have an explicit dot product operation
but might allow you to transpose a vector instead, in which case you can use matrix multiplication on the "vectors" in order to compute the dot products, for example,
using the superscript $T$ to indicate a transpose, as in $mathbf v^T,$
$$
x = (mathbf p - mathbf p_0)^T mathbf e_1.
$$
add a comment |
up vote
0
down vote
Since this is a math site, I'll answer this in a mathematical format.
It will probably translate relatively directly to whatever software library
you are currently using.
The first step is to identify the 3D coordinates of the following points:
$mathbf p_0,$ the point that has coordinates $(0,0)$ according to the 2D coordinate system;
$mathbf p_1,$ the point that has coordinates $(1,0)$ according to the 2D coordinate system;
$mathbf p_2,$ the point that has coordinates $(0,1)$ according to the 2D coordinate system.
That is, the three points $mathbf p_0,$ $mathbf p_1,$ and $mathbf p_2,$
which describe the origin of the 2D coordinates and points on the two axes of the 2D coordinates, have 3D coordinates that could be written as column vectors like this:
$$
mathbf p_0 = begin{pmatrix} p_{01} \ p_{02} \ p_{03} end{pmatrix},quad
mathbf p_1 = begin{pmatrix} p_{11} \ p_{12} \ p_{13} end{pmatrix},quad
mathbf p_2 = begin{pmatrix} p_{21} \ p_{22} \ p_{23} end{pmatrix}.
$$
From these points we can derive two vectors:
$mathbf e_1 = mathbf p_1 - mathbf p_0$
and $mathbf e_2 = mathbf p_2 - mathbf p_0,$
where the subtraction is a componentwise vector operation.
Now to translate any 2D coordinates $(x,y)$ into 3D coordinates, you perform scalar multiplication (scaling) and componentwise addition of these vectors to produce a 3D point $mathbf p$:
$$ mathbf p = mathbf p_0 + x mathbf e_1 + y mathbf e_2. $$
(That is, $xmathbf e_1$ multiplies each coordinate of $mathbf e_1$ by $x,$
and so forth.)
If your library supports matrices and matrix multiplication (which seems likely),
you can put the coordinates of $mathbf e_1$ and $mathbf e_2$ side by side in two columns within a matrix,
and then for any 2D coordinates $(x,y)$ peform the following matrix multiplication,
which produces a $3$-element column vector:
$$
mathbf p =
mathbf p_0 +
begin{pmatrix} e_{11} & e_{21} \ e_{12} & e_{22} \ e_{13} & e_{23} end{pmatrix}
begin{pmatrix} x \ y end{pmatrix}
$$
And that is how you convert any 2D coordinates to 3D.
To convert in the opposite direction, from 3D to 2D, I'll assume you want orthogonal projection, that is, you want to map each point in the 3D space to the closest point in the 2D plane.
You do this with the same vectors $mathbf e_1$ and $mathbf e_2$ that you used for the 2D-to-3D transformation,
as well as the 3D coordinates $mathbf p_0$ of the origin of the 2D system.
Given a point in 3D coordinates, expressed as a column vector $mathbf p,$
take the following dot products (aka inner products):
begin{align}
x &= (mathbf p - mathbf p_0) cdot mathbf e_1, \
y &= (mathbf p - mathbf p_0) cdot mathbf e_2.
end{align}
Then $(x,y)$ are the desired 2D coordinates.
Depending on your library, it might not have an explicit dot product operation
but might allow you to transpose a vector instead, in which case you can use matrix multiplication on the "vectors" in order to compute the dot products, for example,
using the superscript $T$ to indicate a transpose, as in $mathbf v^T,$
$$
x = (mathbf p - mathbf p_0)^T mathbf e_1.
$$
add a comment |
up vote
0
down vote
up vote
0
down vote
Since this is a math site, I'll answer this in a mathematical format.
It will probably translate relatively directly to whatever software library
you are currently using.
The first step is to identify the 3D coordinates of the following points:
$mathbf p_0,$ the point that has coordinates $(0,0)$ according to the 2D coordinate system;
$mathbf p_1,$ the point that has coordinates $(1,0)$ according to the 2D coordinate system;
$mathbf p_2,$ the point that has coordinates $(0,1)$ according to the 2D coordinate system.
That is, the three points $mathbf p_0,$ $mathbf p_1,$ and $mathbf p_2,$
which describe the origin of the 2D coordinates and points on the two axes of the 2D coordinates, have 3D coordinates that could be written as column vectors like this:
$$
mathbf p_0 = begin{pmatrix} p_{01} \ p_{02} \ p_{03} end{pmatrix},quad
mathbf p_1 = begin{pmatrix} p_{11} \ p_{12} \ p_{13} end{pmatrix},quad
mathbf p_2 = begin{pmatrix} p_{21} \ p_{22} \ p_{23} end{pmatrix}.
$$
From these points we can derive two vectors:
$mathbf e_1 = mathbf p_1 - mathbf p_0$
and $mathbf e_2 = mathbf p_2 - mathbf p_0,$
where the subtraction is a componentwise vector operation.
Now to translate any 2D coordinates $(x,y)$ into 3D coordinates, you perform scalar multiplication (scaling) and componentwise addition of these vectors to produce a 3D point $mathbf p$:
$$ mathbf p = mathbf p_0 + x mathbf e_1 + y mathbf e_2. $$
(That is, $xmathbf e_1$ multiplies each coordinate of $mathbf e_1$ by $x,$
and so forth.)
If your library supports matrices and matrix multiplication (which seems likely),
you can put the coordinates of $mathbf e_1$ and $mathbf e_2$ side by side in two columns within a matrix,
and then for any 2D coordinates $(x,y)$ peform the following matrix multiplication,
which produces a $3$-element column vector:
$$
mathbf p =
mathbf p_0 +
begin{pmatrix} e_{11} & e_{21} \ e_{12} & e_{22} \ e_{13} & e_{23} end{pmatrix}
begin{pmatrix} x \ y end{pmatrix}
$$
And that is how you convert any 2D coordinates to 3D.
To convert in the opposite direction, from 3D to 2D, I'll assume you want orthogonal projection, that is, you want to map each point in the 3D space to the closest point in the 2D plane.
You do this with the same vectors $mathbf e_1$ and $mathbf e_2$ that you used for the 2D-to-3D transformation,
as well as the 3D coordinates $mathbf p_0$ of the origin of the 2D system.
Given a point in 3D coordinates, expressed as a column vector $mathbf p,$
take the following dot products (aka inner products):
begin{align}
x &= (mathbf p - mathbf p_0) cdot mathbf e_1, \
y &= (mathbf p - mathbf p_0) cdot mathbf e_2.
end{align}
Then $(x,y)$ are the desired 2D coordinates.
Depending on your library, it might not have an explicit dot product operation
but might allow you to transpose a vector instead, in which case you can use matrix multiplication on the "vectors" in order to compute the dot products, for example,
using the superscript $T$ to indicate a transpose, as in $mathbf v^T,$
$$
x = (mathbf p - mathbf p_0)^T mathbf e_1.
$$
Since this is a math site, I'll answer this in a mathematical format.
It will probably translate relatively directly to whatever software library
you are currently using.
The first step is to identify the 3D coordinates of the following points:
$mathbf p_0,$ the point that has coordinates $(0,0)$ according to the 2D coordinate system;
$mathbf p_1,$ the point that has coordinates $(1,0)$ according to the 2D coordinate system;
$mathbf p_2,$ the point that has coordinates $(0,1)$ according to the 2D coordinate system.
That is, the three points $mathbf p_0,$ $mathbf p_1,$ and $mathbf p_2,$
which describe the origin of the 2D coordinates and points on the two axes of the 2D coordinates, have 3D coordinates that could be written as column vectors like this:
$$
mathbf p_0 = begin{pmatrix} p_{01} \ p_{02} \ p_{03} end{pmatrix},quad
mathbf p_1 = begin{pmatrix} p_{11} \ p_{12} \ p_{13} end{pmatrix},quad
mathbf p_2 = begin{pmatrix} p_{21} \ p_{22} \ p_{23} end{pmatrix}.
$$
From these points we can derive two vectors:
$mathbf e_1 = mathbf p_1 - mathbf p_0$
and $mathbf e_2 = mathbf p_2 - mathbf p_0,$
where the subtraction is a componentwise vector operation.
Now to translate any 2D coordinates $(x,y)$ into 3D coordinates, you perform scalar multiplication (scaling) and componentwise addition of these vectors to produce a 3D point $mathbf p$:
$$ mathbf p = mathbf p_0 + x mathbf e_1 + y mathbf e_2. $$
(That is, $xmathbf e_1$ multiplies each coordinate of $mathbf e_1$ by $x,$
and so forth.)
If your library supports matrices and matrix multiplication (which seems likely),
you can put the coordinates of $mathbf e_1$ and $mathbf e_2$ side by side in two columns within a matrix,
and then for any 2D coordinates $(x,y)$ peform the following matrix multiplication,
which produces a $3$-element column vector:
$$
mathbf p =
mathbf p_0 +
begin{pmatrix} e_{11} & e_{21} \ e_{12} & e_{22} \ e_{13} & e_{23} end{pmatrix}
begin{pmatrix} x \ y end{pmatrix}
$$
And that is how you convert any 2D coordinates to 3D.
To convert in the opposite direction, from 3D to 2D, I'll assume you want orthogonal projection, that is, you want to map each point in the 3D space to the closest point in the 2D plane.
You do this with the same vectors $mathbf e_1$ and $mathbf e_2$ that you used for the 2D-to-3D transformation,
as well as the 3D coordinates $mathbf p_0$ of the origin of the 2D system.
Given a point in 3D coordinates, expressed as a column vector $mathbf p,$
take the following dot products (aka inner products):
begin{align}
x &= (mathbf p - mathbf p_0) cdot mathbf e_1, \
y &= (mathbf p - mathbf p_0) cdot mathbf e_2.
end{align}
Then $(x,y)$ are the desired 2D coordinates.
Depending on your library, it might not have an explicit dot product operation
but might allow you to transpose a vector instead, in which case you can use matrix multiplication on the "vectors" in order to compute the dot products, for example,
using the superscript $T$ to indicate a transpose, as in $mathbf v^T,$
$$
x = (mathbf p - mathbf p_0)^T mathbf e_1.
$$
answered Nov 21 at 21:04
David K
52k340114
52k340114
add a comment |
add a comment |
Thanks for contributing an answer to Mathematics Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3007739%2ftransformation-matrix-between-a-2d-and-a-3d-coordinate-system%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Sorry I don't understand what are you saying, I'm not a computer scientist.
– P De Donato
Nov 21 at 14:14
1
You're not going to be able to get an invertable linear transformation since the dimensions don't match. What you probably want is a projection. en.wikipedia.org/wiki/Projection_(linear_algebra)
– Wintermute
Nov 21 at 14:14