danielepanozzo / cg-old

44 stars 16 forks source link

[Assignment 1] if condition regarding the example program #70

Closed LihengGong closed 5 years ago

LihengGong commented 5 years ago

In part 2 in the example program, there is one if condition

 if (ray_on_xy.norm()<sphere_radius)
            {
                // The ray hit the sphere, compute the exact intersection point
                Vector3d ray_intersection(ray_on_xy(0),ray_on_xy(1),
                        sqrt(sphere_radius*sphere_radius - ray_on_xy.squaredNorm()));
                .....
           }

Question is: Is this if condition just an optimization or is it part of the ray tracing algorithm?
My understanding from the lecture notes is that for orthographic, all the ray’s starting points formed a square instead of a circle.

Thank you

hankstag commented 5 years ago

yes, it's just a simple way to test whether the ray intersects with the sphere in the example case; you need to modify it

LihengGong commented 5 years ago

Thank you.