diff --git a/include/vec3.h b/include/vec3.h index 6ae41b9..f09eeec 100644 --- a/include/vec3.h +++ b/include/vec3.h @@ -47,7 +47,7 @@ class vec3 { bool near_zero() const { - // Return true if the vector is close to zero in all dimensions. + auto s = 1e-8; return (std::fabs(e[0]) < s) && (std::fabs(e[1]) < s) && (std::fabs(e[2]) < s); } @@ -61,11 +61,10 @@ class vec3 { } }; -// point3 is just an alias for vec3, but useful for geometric clarity in the code. + using point3 = vec3; -// Vector Utility Functions inline std::ostream& operator<<(std::ostream& out, const vec3& v) { return out << v.e[0] << ' ' << v.e[1] << ' ' << v.e[2]; @@ -131,7 +130,7 @@ inline vec3 random_unit_vector() { 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 + if (dot(on_unit_sphere, normal) > 0.0) return on_unit_sphere; else return -on_unit_sphere;