0

I understand the concept of $1$ point projection:

As a $3d$ point gets closer to the vanishing point (further on the $z$ axis), the x and y values of the corresponding $2d$ screen point get closer to the $x,y$ of the vanishing point.

I just don't know what this relationship is.

I assume it will include a $y = m/x$ relationship as the z position will never reach the z value of the vanishing point (infinity). How I think it will work

In the image I have a diagonal line from the projected point to the vanishing point labled d, for distance, and I think $d = 1/z$ (or some other constant in place of $1$). However, I don't know how I would calculate the values for $ScreenX$, and $ScreenY$.

Please don't give answers only in matrix form as I intend to use them in some code I am writing, and I'm not yet confident enough to turn matrices into single equations.

Edit: I think my question is asking the same as: One-point perspective formula and https://stackoverflow.com/questions/56559793/one-point-perspective-and-point-with-negative-depth

  • If $\theta$ is the angle between d and the horizontal line, x=d $\cos\theta$, y=d $\sin\theta$. – Star Bright Mar 19 '21 at 19:56
  • But I don't know what theta is. (I know it is an angle) – The Jas1001 Mar 19 '21 at 20:03
  • If you know any two of d, screenx, screeny, you can get it, say screenx=1,screeny=1, then $\tan\theta$=1/1=1, $\theta$=45$^o$. check for details. https://www.mathsisfun.com/algebra/trig-inverse-sin-cos-tan.html – Star Bright Mar 19 '21 at 20:13
  • I suppose I might be able to find θ between the 3d point's x,y, and the x,y of the vanishing point. I'll search for that. – The Jas1001 Mar 19 '21 at 20:54

1 Answers1

0

I was talking about this with some people on Discord and one gave me this answer: (I got permission to post it here)

the correct function is: f(x,y,z) = (x/z, y/z)

then z is the depth in the scene and you can move back and forward with f(x,y,z,t) = (x/(z-t), y/(z-t)) where t is the camera z position

generally, if you have a camera transformation, you apply that before the projection transformation

f(x-a,y-b,z-c) = ((x-a)/(z-c),(y-b)/(z-c)) to translate the camera so that (a,b,c) is the origin

later you might want to apply scaling or rotation to the camera. but notice that you subtract rather than add to translate the camera. the same rule applies to scaling and rotation. generally you transform by the inverse of the camera matrix before you project