Skip to content

Book1 Listing 35: Possible sphere intersection logic error #1727

@theAnuragMishra

Description

@theAnuragMishra

After introducing theInterval class, the intersection code is updated to

if (!ray_t.surrounds(root)) {
            root = (h + sqrtd) / a;
            if (!ray_t.surrounds(root))
                return false;
        }

Shouldn't it use contains instead though?
The given code rejects a root that is equal to t_min or t_max.

Well while writing this I went to the book again and saw it rejects such roots before introducing the Interval class too. But again the meaning of t_min or t_max to me is that they are inside the acceptable value boundary. t_min or minimum time sounds like the minimum acceptable value of time.

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