Skip to content

Book 1 Chapter 5.2: hit_sphere function -- fix discriminant test #1058

@hollasch

Description

@hollasch

Discussed in #1057

Originally posted by LollipopFt August 20, 2022
in the last line of hit_sphere, the code is:

return (discriminant > 0);

however, earlier in the same chapter the book mentioned

either positive (meaning two real solutions), negative (meaning no real solutions), or zero (meaning one real solution)

doesn't this mean the code should instead be

return (discriminant >= 0)

since discriminant = 0 means that the ray still touches the sphere and should thus be included?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions