# How to convert a 2d point into a 3d point ?

• Apr 18th 2005, 06:48 AM
damiano
How to convert a 2d point into a 3d point ?
To create 3d graphism i use a formula that convert a 3d point into a 2d point that i can draw on the screen.
Now how can i do the inverse ? : convert a 2d point into a 3d point.

Here is the formula :
d and r are focal parameters.
n and n1 are used to center the drawing on the form.
(I use : d=2000, r=2000, n=400, n1=400)
xe and ye are the coordinates and the result of the formula.
x,y and z are the 3d coordinates of the point.
d,r,n and n1 are known.

b=y-z+r

xe=(d*x)/b+n

ye=n1-(d*y)/b

Thanks.
• Apr 18th 2005, 06:40 PM
beepnoodle
From your formula, it looks like this might be the transformation from 3d to 2d,
T(x,y,z) = ((d*x)/b+n , n1-(d*y)/b)
• Apr 19th 2005, 01:48 AM
damiano
We can write this :

z=(n1-ye)*b/d+r-b

we have all the parameters on the right so we get z.

In my sample we have xe,ye (the coordinate of the 2d point)
xe=623 and ye=160

n and n1 (parameter to center the drawing on the screen)
n1=342 and n=442

d and r the focal of the camera.
d=2000 and r=2000

we can rewrite this : z=(n1-ye)*b/d+r-b

to get : b=

I don't know how to reformulate this last line. Can you help me ?

Thanks.
• Apr 19th 2005, 10:37 AM
ticbol
Okay, I will only show how to get or isolate the "b".
I don't understand the whole solution as shown. The topic is beyond me.

z=(n1-ye)*b/d+r-b

If that is
z = b(n1 -ye) / (d +r -b),
then,

Clear the fraction, multiply both sides by (d +r -b),
z(d +r -b) = b(n1 -ye)
z(d +r) -z(b) = b(n1 -ye)
Collect the b-terms,
z(d +r) = b(n1 -ye) +bz
z(d +r) = b[(n1 -ye) +z]
z(d +r) = b(n1 -ye +z)
Divide both sides by (n1 -ye +z),
b = z(d+r) / (n1 -ye +z) ....answer.
• Apr 20th 2005, 01:36 AM
damiano
finaly i get this that works :

z = (n1-ye) * (b/d) + r -b

consequence : d(z-r) = (n1-ye)*b - d*b

consequence : b = d(z-r) / (n1-ye-d)
• Apr 20th 2005, 02:17 AM
ticbol
Umm, so it is actually
z = (n1-ye) * (b/d) + r -b

Then, yes, you are right,
b = d(z-r) / (n1-ye-d)
• Apr 20th 2005, 07:30 AM
damiano
Thanks very much for your help.