# How can i calculate the direction vector of a pixel? [closed]

So if you take a pinhole camera and make it as the origin of our plane(3D) and a pixel from the image plane and connect the two with a straight line it should make a vector, which has direction and a length. Think of this as the path followed by the light reflected from an object into the camera lens. And i want to calculate this. I think we have to use the cameras intrinsic properties for this.

In a pinhole camera model, each pixel defines a direction vector in 3D space, specifically the vector from the projection center through the pixel's position on the image plane.

Below is an image better explaining this. I want to calculate the three red lines, and known parameters would be, i guess, the camera position(origin) and the image pixel value, and the intrinsic camera parameters.

• Where oh where did you get that image? – OnBreak. Dec 20 '19 at 8:46
• See this. If you know the focal length and the pixel position from the center (pixel coordinates factored by sensor pixel density), you know the angle of the view ray. – xenoid Dec 20 '19 at 9:25
• I'm voting to close this question as off-topic because it is a math/engineering question. – xenoid Dec 20 '19 at 9:26
• @Hueco i googled ray tracing and in the images tab....i found it after a couple scrolls. I had seen a similar image thought i could find it but this worked too... upload.wikimedia.org/wikipedia/commons/thumb/8/83/… – rockangator Dec 20 '19 at 10:39
• @Hueco The OPs image seems to be representation of a 3D image render. You have the 3D scene objects in front of the plane. The camera object represents the location, aspect ratio and field of view of the observer and the image represents the plane (monitor screen) onto where the 2D image of the 3D scene is projected. The use of "camera" in this case is a standard in 3D graphics. – Peter M Dec 20 '19 at 15:06