<p>Here I try to combine scratchapixel's articles to understand the operation of the camera-to-world matrix and ray direction vector. Here <a href="https://www.scratchapixel.com/lessons/3d-basic-rendering/ray-tracing-generating-camera-rays/generating-camera-rays.html" rel="nofollow noreferrer">https://www.scratchapixel.com/lessons/3d-basic-rendering/ray-tracing-generating-camera-rays/generating-camera-rays.html</a> if you scroll the last part is about generating a direction vector without converting pixel coordinates from raster space to NDC, then to screen. I decided to take that approach. But, after multiplying the direction vector with the camera-to-world matrix, there is no added translation vector to the direction vector's coordinates (that is the 4th vector of the matrix). Maybe the camera is placed at (0,0,0). Idk. Also, are LookAt and camera-to-world matrices the same thing?</p>

CC BY-SA 4.0
2023-06-28T11:56:21.063Z
Welcome to computer graphics stack exchange! the `lookAt` matrix transforms world coordinates to camera coordinates. The inverse of the `lookAt` matrix transforms camera coordinates to world coordinates.
Thomas
CC BY-SA 4.0
2023-06-28T12:31:58.883Z
Adding to @Thomas answer: The  `lookAt` matrix is *A* but not *THE* world-to-camera matrix. The same is true for the inverse. A "look at"-camera represents a camera model where the camera is focused on a point in space like in most strategy games. FPS use a different camera model, but the corresponding matrix that transforms between the camera and world coordinate system is also a camera-to-world matrix.
wychmaster
CC BY-SA 4.0
2023-06-28T15:07:32.357Z
I got it. I am mainly interested in whether does row-majored LookAt matrix contains the camera's coordinates as its 4th row. I know that camera-to-world contains it.
Zhenya Karapetyan
CC BY-SA 4.0
2024-05-21T11:54:39.130Z
Whether the LookAt matrix is the cam-to-world or world-to-cam is arguable. I'd say it's the cam to world not the opposite to the contrary of what's said above. The LookAt method doesn't inform you about the convention used for the matrix. Scratchapixel uses row-major matrices and the right hand coordinate system. So translation values would be in 4th row.
user18490
<raytracing>
Defining ray direction vector
Zhenya Karapetyan
# Defining ray direction vector

(Asked by: username_0 on 2023-06-28)

Here I try to combine scratchapixel's articles to understand the operation of the camera-to-world matrix and ray direction vector. Here <https://www.scratchapixel.com/lessons/3d-basic-rendering/ray-tracing-generating-camera-rays/generating-camera-rays.html> if you scroll the last part is about generating a direction vector without converting pixel coordinates from raster space to NDC, then to screen. I decided to take that approach. But, after multiplying the direction vector with the camera-to-world matrix, there is no added translation vector to the direction vector's coordinates (that is the 4th vector of the matrix). Maybe the camera is placed at (0,0,0). Idk. Also, are LookAt and camera-to-world matrices the same thing?

**Tags:** raytracing

> **Comments:**
> **username_1**: Welcome to computer graphics stack exchange! the `lookAt` matrix transforms world coordinates to camera coordinates. The inverse of the `lookAt` matrix transforms camera coordinates to world coordinates.  
> **username_2**: Adding to @username_1 answer: The  `lookAt` matrix is *A* but not *THE* world-to-camera matrix. The same is true for the inverse. A "look at"-camera represents a camera model where the camera is focused on a point in space like in most strategy games. FPS use a different camera model, but the corresponding matrix that transforms between the camera and world coordinate system is also a camera-to-world matrix.  
> **username_0**: I got it. I am mainly interested in whether does row-majored LookAt matrix contains the camera's coordinates as its 4th row. I know that camera-to-world contains it.  
> **username_3**: Whether the LookAt matrix is the cam-to-world or world-to-cam is arguable. I'd say it's the cam to world not the opposite to the contrary of what's said above. The LookAt method doesn't inform you about the convention used for the matrix. Scratchapixel uses row-major matrices and the right hand coordinate system. So translation values would be in 4th row.  

---

## 0 answers

