Jump to content
  • Advertisement
Sign in to follow this  

2D shape to 3D space view

This topic is 2549 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

[font="Arial, Helvetica, sans-serif"][size="4"][size="4"][size="4"]Given a maximum of four points in a 2D space, x0,y0 x1,y1 x2,y2 x3,y3. [/font]
[font="Arial, Helvetica, sans-serif"][size="4"][size="4"][size="4"]The 2D space is limited to X 0...1 and Y 0...1.[/font]
[font="Arial, Helvetica, sans-serif"][size="4"][size="4"][size="4"]The points in the sequence 0,1,2,3,0 represent a rectangle (let's say the snapshot of a paper with a camera).[/font]
[font="Arial, Helvetica, sans-serif"][size="4"][size="4"] [/font]
[font="Arial, Helvetica, sans-serif"][size="4"][size="4"][size="4"]I need to know the 3D position of the camera, its orientation vector, view angle, 3D coordinates of the points of the rectangle in the 3D space. Of course there are some missing informations to limit the number of solutions, which is not a problem.

[size="4"]The reply i had in a math forum has been "This is a rather basic Transformation. Here is a great site for this type of question: gamedev.net/index Do a search there, this question has been asked there about a hundred times."

[size="4"]Thanks for a simple algorithm to have an approximate solution, or to any link to page or article solving the problem.


Share this post

Link to post
Share on other sites

Of course there are some missing informations...

Yeah, rather a lot of missing information actually. In what sense can there be a 3D position of the camera, or of the rectangle in 3D space if it is only defined in 2D?

If you mean a camera pointing straight at the rectangle, you need to define the Z position of your rectangle. The camera position is then simply the centre position of your rectangle plus or minus the Z distance of the camera from the rectangle (also completely undefined in your example), the look vector would be (0,0,1) or (0,0,-1) depending on which direction your Z goes.

But I suspect I'm barking up a random tree here. Could you please state the problem in terms of what you are actually trying to do, or link to your other thread?

Share this post

Link to post
Share on other sites
You're right, i can expose better the problem. So let me do in a more concrete way.

You've got a camera and take a snapshot of a (rectangular) paper lying on a table.
I get that picture, use as a flat background and setup an OpenGL scene in the way that the paper i have a quad with coordinates, let's say (0,0,0) (1,0,0) (1,2,0) (0,2,0).
This way i can replace the "paper" with an image that i need, with correct perspective, indipendent from the the snapsho angle, etc.

In other words, i would like reproduce the same algorithms behind photoshop's "vanishing point" function.

I suspect there are some other variables to "decide" to have a single output solution, this is not a problem.

Thanks for your help.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!