Skip to content

Confusion inverse vector figure 13 in Ray Tracing In One Weekend #1718

@thibaultdupont-cpe

Description

@thibaultdupont-cpe

Hi,

I think Figure 13 is confusing when compared to Code Listing 45.

and

inline vec3 random_on_hemisphere(const vec3& normal) {
    vec3 on_unit_sphere = random_unit_vector();
    if (dot(on_unit_sphere, normal) > 0.0) // In the same hemisphere as the normal
        return on_unit_sphere;
    else
        return -on_unit_sphere;
}

The drawing suggests a symmetry over the plane, whereas the code returns the inverse vector (which is also what the text explains). While both approaches preserve the probabilistic distribution, a new drawing could help avoid this confusion.

It could also be possible to apply the symmetry using:

return on_unit_sphere-2*dot(on_unit_sphere, normal)*normal;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions