Skip to content

Commit e3f3f84

Browse files
authored
Removed add/sub of small floats to/from large ones
A vector was added to a point and then the point was immediately subtracted to recover the original vector, but with some possible precision loss as the vector can be very small.
1 parent 7155928 commit e3f3f84

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

books/RayTracingInOneWeekend.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2007,9 +2007,9 @@
20072007

20082008
if (world.hit(r, interval(0.001, infinity), rec)) {
20092009
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
2010-
point3 target = rec.p + random_in_hemisphere(rec.normal);
2010+
vec3 direction = random_in_hemisphere(rec.normal);
2011+
return 0.5 * ray_color(ray(rec.p, direction), world, depth-1);
20112012
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
2012-
return 0.5 * ray_color(ray(rec.p, target - rec.p), world, depth-1);
20132013
}
20142014

20152015
vec3 unit_direction = unit_vector(r.direction());

0 commit comments

Comments
 (0)