File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change 559
559
If we take that math and hard-code it into our program, we can test it by coloring red any pixel
560
560
that hits a small sphere we place at -1 on the z-axis:
561
561
562
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
562
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
563
563
bool hit_sphere(const vec3& center, double radius, const ray& r) {
564
564
vec3 oc = r.origin() - center;
565
565
auto a = dot(r.direction(), r.direction());
568
568
auto discriminant = b*b - 4*a*c;
569
569
return (discriminant > 0);
570
570
}
571
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
571
572
572
573
573
574
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
1094
1095
< div class='together'>
1095
1096
And the new main:
1096
1097
1097
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
1098
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
1098
1099
#include "rtweekend.h"
1099
1100
1100
1101
#include "hittable_list.h"
1101
1102
#include "sphere.h"
1103
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
1102
1104
1103
1105
#include < iostream>
1104
1106
You can’t perform that action at this time.
0 commit comments