Back project square from 2D to 3D

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

Recommended Posts

Dear experts, I am working on a project where i need to do back-projection of points on screen to their 3D wolrd positions and i need your help in this regards. I have 4 fixed points that represent a square in 3D world parallel to the X-Z plane. After applying transformation effects (rotation and translation) these points get projected to arbitrary points on screen (2D). I need to project back these points from screen coordinates to their actual 3D points keeping in mind preserving the square shape they represent. For example: 3D World 2D Screen the square *-------* *---* | | could be projected to / \ | | (perpective) / | | *---------* *-------* or roughly to * (perspective and / rotation) / \ * * \ / \ / * can any one help please? cheers AF

Share on other sites
Ops, the formating was not preserved? How can i reserve ot and keep the spacing?

Share on other sites
use [ code ] and [ /code ] tags around your ASCII art to preserve formatting (though it might not be exactly what it is when you edit it. Eg: it uses a different font.

Share on other sites
Hi again,

this is the example i wanted to give in my post witht he proper formating (thanx Ezbez)

For example:the square in 3D:              o-------o	        |	|        |	|        |	|        o-------ocould be projected to in 2D(perpectivei applied):         o------o       /        /                /         /      /          /    o-----------oor roughly to (perspective and rotation)	              o	   / \	         /     \		       o	 o	 \     /	   \ /	    o

[Edited by - abolfoooud on May 10, 2007 6:38:08 AM]

Share on other sites
If what you need are the coordinates of the untransformed vertexes, then what you need to do is transform the screen-space coordinates using the inverse of the original transformation, which is:
Vs = M . Vw

where Vs is in screen space and Vw is in world space and M is a matrix representing the transformation from world to screen space (most likely a concatenation of a projection matrix and a view matrix).

Given Vs = ( xs, ys, zs ) (the 2D coordinates of each vertex on the screen and a screen space depth), compute the inverse of M, M-1 to get Vw:
Vw = M-1 . Vs

If you do not have a screen space depth, you can substitute for 0 and 1. What you then get is a line of sight starting from the camera (given M has a view matrix) to infinity, passing through Vw at some time t.

Share on other sites

now 2 ueastions:

1) what do you mean by screen depth and how do i get it?

2) how do i get the inverse of the transformation matrix?

regards
AF

Share on other sites
It's good practice to know the general way to solve these problems, even though you could take short cuts in this particular case. Given all the information you know about the starting data, you can use different means to find your answer. The general solution to this problem though is to find the inverse matrix, which is done [for square matrices] by dividing every term in the matrix by the non-zero determinant. If the determinant is zero, then there is no inverse. You won't run into a zero-determinant in these cases, unless you're doing something amazingly wierd with your original transform matrix.

By the way, thats a great site for just these kinds of problems. It's definately bookmark-worthy.

Share on other sites
the site gives example of how apply the inverse of 3x3 matrix. but in the case of OGL we need 4x4. calculating this for 4x4 will be i am sure tooo ime costy and will affect performance. i read somewhere that there are shortcuts or work-arounds to get the inverse.

also the site has theoratical explanation. is there a technical one showing opengl code to use? i know i am too lazy :D

cheers

1. 1
Rutin
23
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 9
• 33
• 41
• 23
• 13
• Forum Statistics

• Total Topics
631745
• Total Posts
3002000
×