karansher / computer-graphics-ray-casting

Computer Graphics Assignment about Ray Casting
1 stars 0 forks source link

Camera space vs world space #23

Open FarzanehCS opened 1 year ago

FarzanehCS commented 1 year ago

Hi, While I was studying the slides, I feel in this slide we should say, we are going from the world space to the camera space. So saying we are going to the world space appears wrong to me!

image

The reasoning for me is that here we use a matrix called the `camera’s transformation matrix, to project the u_i, v_j, and -d (that are in the world space already) to the “camera’s space”. This is I think consistent with the A2 as well. Since we use the position of the camera and map it to real-world space.

I was wondering if you could guide and correct me if I am misunderstanding sth. Thank you.

Ming-Yeung-Alfred-Meng commented 1 year ago

It's converting points in the camera space to the world space.

Assume (0, 0, 0) is the origin of the world space.

in the camera space, the origin is e (which is not necessarily (0, 0, 0)), and the elementary vectors that define the space are u, v, and w, (which again are not necessarily (1, 0, 0), (0, 1, 0) and (0, 0, 1)). The point (u(i), v(j), -d) is the position of the pixel in the ith row and jth column in the camera space/camera's coordinate system.

We need to convert (u(i), v(j), -d) to it's representation in the world space, which is u(i)U + v(j)V - dW.

This conversion uses the linear algebra notion of changing representation of points between bases.

Ming-Yeung-Alfred-Meng commented 1 year ago

Let me know if there is anything that's unclear. After reading my own comment I feel like there are a lot of spaces where details can be added.

FarzanehCS commented 1 year ago

Thank you. Yea I understand the concept of changing spaces by a transformation. My point is that, here it is like we are initially in the "world space" (i.e. the "image plane" is in the "world space") and then we fix our camera at a specific point in this space. That will give the camera the u, v, and w base vectors which define where the camera is fixed. Then we use the u, v, and w vectors in a matrix called a camera transformation matrix to then map each point of the world space to this camera space. That is why we call this matrix the camera transformation matrix since it maps us to its world.

Is this logic not correct?

panuelosj commented 1 year ago

Camera space is a basis where (0,0,0) is the origin of a camera pointed at (0,0,-1). World space is a basis where (0,0,0) is the origin, but the camera is positioned at some (ex,ey,ez) and pointed at some -(wx,wy,wz) direction. The camera transformation matrix (plus the e offset) will convert some coordinates from this camera space to the world space.

The idea is, you actually start in camera space (since it's easier to construct the ray vectors here given that the camera origin is at (0,0,0)), then you transform this vector into our world space basis.