How to transform point in 2d into 3d?












1












$begingroup$


This is not a homework, I simply have to write some code and it appears my math skills are a bit rusty ;-).



What I have: main point in 2d of the 2d surface, and main point counterpart in 3d plus the normal vector to the 3d surface. I also have 3d counterpart of (0,1) vector from 2d.



My input is some point in 2d and my objective is to compute its coordinates in 3d. How to do it?



If you wonder what is it -- it is quite simple, I have my screen, as usual, the user clicks on the screen, so I have my (x,y) for the mouse coordinates and I have to take the screen surface and shift+rotate it in 3d to get the center of screen located in the "main" point (camera) in 3d and then find out the coordinates of the mouse click in 3d on this rotated surface.



This would give infinite number of solutions, but I also have given the 3d counterpart of (0,1) vector and the normal vector to the 3d surface (the direction of view) so it should be doable (I mean with 1 outcome).










share|cite|improve this question











$endgroup$












  • $begingroup$
    Please describe the rotated surface that the mouse click is projected onto. Is it a plane? A sphere? A Mickey Mouse head?
    $endgroup$
    – vadim123
    Feb 12 '14 at 14:35










  • $begingroup$
    @vadim123, it is still a surface (flat) in such way, that let's say my (0,1) vector is transformed into vector UP (in 3d). UP is given as input (it is known).
    $endgroup$
    – greenoldman
    Feb 12 '14 at 14:39










  • $begingroup$
    Please have a look here : en.m.wikipedia.org/wiki/3D_projection
    $endgroup$
    – Yiyuan Lee
    Feb 12 '14 at 14:45










  • $begingroup$
    Not enough info to find a unique solution, IMO.
    $endgroup$
    – bubba
    Feb 12 '14 at 14:45










  • $begingroup$
    @YiyuanLee, for the record I am for a "mapping" 2d into 3d (while 3d projection is mapping 3d into 2d)
    $endgroup$
    – greenoldman
    Feb 12 '14 at 15:00
















1












$begingroup$


This is not a homework, I simply have to write some code and it appears my math skills are a bit rusty ;-).



What I have: main point in 2d of the 2d surface, and main point counterpart in 3d plus the normal vector to the 3d surface. I also have 3d counterpart of (0,1) vector from 2d.



My input is some point in 2d and my objective is to compute its coordinates in 3d. How to do it?



If you wonder what is it -- it is quite simple, I have my screen, as usual, the user clicks on the screen, so I have my (x,y) for the mouse coordinates and I have to take the screen surface and shift+rotate it in 3d to get the center of screen located in the "main" point (camera) in 3d and then find out the coordinates of the mouse click in 3d on this rotated surface.



This would give infinite number of solutions, but I also have given the 3d counterpart of (0,1) vector and the normal vector to the 3d surface (the direction of view) so it should be doable (I mean with 1 outcome).










share|cite|improve this question











$endgroup$












  • $begingroup$
    Please describe the rotated surface that the mouse click is projected onto. Is it a plane? A sphere? A Mickey Mouse head?
    $endgroup$
    – vadim123
    Feb 12 '14 at 14:35










  • $begingroup$
    @vadim123, it is still a surface (flat) in such way, that let's say my (0,1) vector is transformed into vector UP (in 3d). UP is given as input (it is known).
    $endgroup$
    – greenoldman
    Feb 12 '14 at 14:39










  • $begingroup$
    Please have a look here : en.m.wikipedia.org/wiki/3D_projection
    $endgroup$
    – Yiyuan Lee
    Feb 12 '14 at 14:45










  • $begingroup$
    Not enough info to find a unique solution, IMO.
    $endgroup$
    – bubba
    Feb 12 '14 at 14:45










  • $begingroup$
    @YiyuanLee, for the record I am for a "mapping" 2d into 3d (while 3d projection is mapping 3d into 2d)
    $endgroup$
    – greenoldman
    Feb 12 '14 at 15:00














1












1








1





$begingroup$


This is not a homework, I simply have to write some code and it appears my math skills are a bit rusty ;-).



What I have: main point in 2d of the 2d surface, and main point counterpart in 3d plus the normal vector to the 3d surface. I also have 3d counterpart of (0,1) vector from 2d.



My input is some point in 2d and my objective is to compute its coordinates in 3d. How to do it?



If you wonder what is it -- it is quite simple, I have my screen, as usual, the user clicks on the screen, so I have my (x,y) for the mouse coordinates and I have to take the screen surface and shift+rotate it in 3d to get the center of screen located in the "main" point (camera) in 3d and then find out the coordinates of the mouse click in 3d on this rotated surface.



This would give infinite number of solutions, but I also have given the 3d counterpart of (0,1) vector and the normal vector to the 3d surface (the direction of view) so it should be doable (I mean with 1 outcome).










share|cite|improve this question











$endgroup$




This is not a homework, I simply have to write some code and it appears my math skills are a bit rusty ;-).



What I have: main point in 2d of the 2d surface, and main point counterpart in 3d plus the normal vector to the 3d surface. I also have 3d counterpart of (0,1) vector from 2d.



My input is some point in 2d and my objective is to compute its coordinates in 3d. How to do it?



If you wonder what is it -- it is quite simple, I have my screen, as usual, the user clicks on the screen, so I have my (x,y) for the mouse coordinates and I have to take the screen surface and shift+rotate it in 3d to get the center of screen located in the "main" point (camera) in 3d and then find out the coordinates of the mouse click in 3d on this rotated surface.



This would give infinite number of solutions, but I also have given the 3d counterpart of (0,1) vector and the normal vector to the 3d surface (the direction of view) so it should be doable (I mean with 1 outcome).







geometry






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Feb 12 '14 at 15:01







greenoldman

















asked Feb 12 '14 at 14:32









greenoldmangreenoldman

1156




1156












  • $begingroup$
    Please describe the rotated surface that the mouse click is projected onto. Is it a plane? A sphere? A Mickey Mouse head?
    $endgroup$
    – vadim123
    Feb 12 '14 at 14:35










  • $begingroup$
    @vadim123, it is still a surface (flat) in such way, that let's say my (0,1) vector is transformed into vector UP (in 3d). UP is given as input (it is known).
    $endgroup$
    – greenoldman
    Feb 12 '14 at 14:39










  • $begingroup$
    Please have a look here : en.m.wikipedia.org/wiki/3D_projection
    $endgroup$
    – Yiyuan Lee
    Feb 12 '14 at 14:45










  • $begingroup$
    Not enough info to find a unique solution, IMO.
    $endgroup$
    – bubba
    Feb 12 '14 at 14:45










  • $begingroup$
    @YiyuanLee, for the record I am for a "mapping" 2d into 3d (while 3d projection is mapping 3d into 2d)
    $endgroup$
    – greenoldman
    Feb 12 '14 at 15:00


















  • $begingroup$
    Please describe the rotated surface that the mouse click is projected onto. Is it a plane? A sphere? A Mickey Mouse head?
    $endgroup$
    – vadim123
    Feb 12 '14 at 14:35










  • $begingroup$
    @vadim123, it is still a surface (flat) in such way, that let's say my (0,1) vector is transformed into vector UP (in 3d). UP is given as input (it is known).
    $endgroup$
    – greenoldman
    Feb 12 '14 at 14:39










  • $begingroup$
    Please have a look here : en.m.wikipedia.org/wiki/3D_projection
    $endgroup$
    – Yiyuan Lee
    Feb 12 '14 at 14:45










  • $begingroup$
    Not enough info to find a unique solution, IMO.
    $endgroup$
    – bubba
    Feb 12 '14 at 14:45










  • $begingroup$
    @YiyuanLee, for the record I am for a "mapping" 2d into 3d (while 3d projection is mapping 3d into 2d)
    $endgroup$
    – greenoldman
    Feb 12 '14 at 15:00
















$begingroup$
Please describe the rotated surface that the mouse click is projected onto. Is it a plane? A sphere? A Mickey Mouse head?
$endgroup$
– vadim123
Feb 12 '14 at 14:35




$begingroup$
Please describe the rotated surface that the mouse click is projected onto. Is it a plane? A sphere? A Mickey Mouse head?
$endgroup$
– vadim123
Feb 12 '14 at 14:35












$begingroup$
@vadim123, it is still a surface (flat) in such way, that let's say my (0,1) vector is transformed into vector UP (in 3d). UP is given as input (it is known).
$endgroup$
– greenoldman
Feb 12 '14 at 14:39




$begingroup$
@vadim123, it is still a surface (flat) in such way, that let's say my (0,1) vector is transformed into vector UP (in 3d). UP is given as input (it is known).
$endgroup$
– greenoldman
Feb 12 '14 at 14:39












$begingroup$
Please have a look here : en.m.wikipedia.org/wiki/3D_projection
$endgroup$
– Yiyuan Lee
Feb 12 '14 at 14:45




$begingroup$
Please have a look here : en.m.wikipedia.org/wiki/3D_projection
$endgroup$
– Yiyuan Lee
Feb 12 '14 at 14:45












$begingroup$
Not enough info to find a unique solution, IMO.
$endgroup$
– bubba
Feb 12 '14 at 14:45




$begingroup$
Not enough info to find a unique solution, IMO.
$endgroup$
– bubba
Feb 12 '14 at 14:45












$begingroup$
@YiyuanLee, for the record I am for a "mapping" 2d into 3d (while 3d projection is mapping 3d into 2d)
$endgroup$
– greenoldman
Feb 12 '14 at 15:00




$begingroup$
@YiyuanLee, for the record I am for a "mapping" 2d into 3d (while 3d projection is mapping 3d into 2d)
$endgroup$
– greenoldman
Feb 12 '14 at 15:00










1 Answer
1






active

oldest

votes


















1












$begingroup$

I assume that by “surface” you actually mean plane.



You can compute the cross product between the image of the $(0,1)$ vector and the normal vector of the 3d plane. That will be a vector orthogonal to both, which you can then consider as the image of the $(1,0)$ vector.



You can then interpret each point $(x,y)$ in the plane as $xcdot(1,0)+ycdot(0,1)$ and translate this to 3d as $v_0 + xcdot v_x + ycdot v_y$. If your “main points” are not the origin of their respective coordinate system, you'd first subtract the 2d “main point”, then do the above conversion to 3d, then add the 3d “main point”. All of this would establish a Cartesian coordinate system on a given plane in 3d.



The “main point” in 3d should however not be the location of the camera, but should instead be a point on the plane. And if your coordinates are coordinates as seen by the camera, then a simple Cartesian coordinate system is not what you need. Instead you'd have to take care of perspective deformations. For that you'd need more information than you provided.






share|cite|improve this answer









$endgroup$













  • $begingroup$
    Absolutely great! Thank you very much for the solution and all the remarks -- they will be very helpful when debugging the code.
    $endgroup$
    – greenoldman
    Feb 13 '14 at 7:46











Your Answer





StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f673827%2fhow-to-transform-point-in-2d-into-3d%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1












$begingroup$

I assume that by “surface” you actually mean plane.



You can compute the cross product between the image of the $(0,1)$ vector and the normal vector of the 3d plane. That will be a vector orthogonal to both, which you can then consider as the image of the $(1,0)$ vector.



You can then interpret each point $(x,y)$ in the plane as $xcdot(1,0)+ycdot(0,1)$ and translate this to 3d as $v_0 + xcdot v_x + ycdot v_y$. If your “main points” are not the origin of their respective coordinate system, you'd first subtract the 2d “main point”, then do the above conversion to 3d, then add the 3d “main point”. All of this would establish a Cartesian coordinate system on a given plane in 3d.



The “main point” in 3d should however not be the location of the camera, but should instead be a point on the plane. And if your coordinates are coordinates as seen by the camera, then a simple Cartesian coordinate system is not what you need. Instead you'd have to take care of perspective deformations. For that you'd need more information than you provided.






share|cite|improve this answer









$endgroup$













  • $begingroup$
    Absolutely great! Thank you very much for the solution and all the remarks -- they will be very helpful when debugging the code.
    $endgroup$
    – greenoldman
    Feb 13 '14 at 7:46
















1












$begingroup$

I assume that by “surface” you actually mean plane.



You can compute the cross product between the image of the $(0,1)$ vector and the normal vector of the 3d plane. That will be a vector orthogonal to both, which you can then consider as the image of the $(1,0)$ vector.



You can then interpret each point $(x,y)$ in the plane as $xcdot(1,0)+ycdot(0,1)$ and translate this to 3d as $v_0 + xcdot v_x + ycdot v_y$. If your “main points” are not the origin of their respective coordinate system, you'd first subtract the 2d “main point”, then do the above conversion to 3d, then add the 3d “main point”. All of this would establish a Cartesian coordinate system on a given plane in 3d.



The “main point” in 3d should however not be the location of the camera, but should instead be a point on the plane. And if your coordinates are coordinates as seen by the camera, then a simple Cartesian coordinate system is not what you need. Instead you'd have to take care of perspective deformations. For that you'd need more information than you provided.






share|cite|improve this answer









$endgroup$













  • $begingroup$
    Absolutely great! Thank you very much for the solution and all the remarks -- they will be very helpful when debugging the code.
    $endgroup$
    – greenoldman
    Feb 13 '14 at 7:46














1












1








1





$begingroup$

I assume that by “surface” you actually mean plane.



You can compute the cross product between the image of the $(0,1)$ vector and the normal vector of the 3d plane. That will be a vector orthogonal to both, which you can then consider as the image of the $(1,0)$ vector.



You can then interpret each point $(x,y)$ in the plane as $xcdot(1,0)+ycdot(0,1)$ and translate this to 3d as $v_0 + xcdot v_x + ycdot v_y$. If your “main points” are not the origin of their respective coordinate system, you'd first subtract the 2d “main point”, then do the above conversion to 3d, then add the 3d “main point”. All of this would establish a Cartesian coordinate system on a given plane in 3d.



The “main point” in 3d should however not be the location of the camera, but should instead be a point on the plane. And if your coordinates are coordinates as seen by the camera, then a simple Cartesian coordinate system is not what you need. Instead you'd have to take care of perspective deformations. For that you'd need more information than you provided.






share|cite|improve this answer









$endgroup$



I assume that by “surface” you actually mean plane.



You can compute the cross product between the image of the $(0,1)$ vector and the normal vector of the 3d plane. That will be a vector orthogonal to both, which you can then consider as the image of the $(1,0)$ vector.



You can then interpret each point $(x,y)$ in the plane as $xcdot(1,0)+ycdot(0,1)$ and translate this to 3d as $v_0 + xcdot v_x + ycdot v_y$. If your “main points” are not the origin of their respective coordinate system, you'd first subtract the 2d “main point”, then do the above conversion to 3d, then add the 3d “main point”. All of this would establish a Cartesian coordinate system on a given plane in 3d.



The “main point” in 3d should however not be the location of the camera, but should instead be a point on the plane. And if your coordinates are coordinates as seen by the camera, then a simple Cartesian coordinate system is not what you need. Instead you'd have to take care of perspective deformations. For that you'd need more information than you provided.







share|cite|improve this answer












share|cite|improve this answer



share|cite|improve this answer










answered Feb 13 '14 at 7:38









MvGMvG

30.8k449101




30.8k449101












  • $begingroup$
    Absolutely great! Thank you very much for the solution and all the remarks -- they will be very helpful when debugging the code.
    $endgroup$
    – greenoldman
    Feb 13 '14 at 7:46


















  • $begingroup$
    Absolutely great! Thank you very much for the solution and all the remarks -- they will be very helpful when debugging the code.
    $endgroup$
    – greenoldman
    Feb 13 '14 at 7:46
















$begingroup$
Absolutely great! Thank you very much for the solution and all the remarks -- they will be very helpful when debugging the code.
$endgroup$
– greenoldman
Feb 13 '14 at 7:46




$begingroup$
Absolutely great! Thank you very much for the solution and all the remarks -- they will be very helpful when debugging the code.
$endgroup$
– greenoldman
Feb 13 '14 at 7:46


















draft saved

draft discarded




















































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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f673827%2fhow-to-transform-point-in-2d-into-3d%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

SQL update select statement

'app-layout' is not a known element: how to share Component with different Modules