|
71 | 71 |
|
72 | 72 |
|
73 | 73 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight |
74 | | - ray(const point3& origin, const vec3& direction) : orig(origin), dir(direction), tm(0) |
75 | | - {} |
76 | | - |
77 | 74 | ray(const point3& origin, const vec3& direction, double time = 0.0) |
78 | 75 | : orig(origin), dir(direction), tm(time) |
79 | 76 | {} |
|
186 | 183 | } |
187 | 184 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ |
188 | 185 |
|
189 | | - ... |
| 186 | + bool hit(const ray& r, interval ray_t, hit_record& rec) const override { |
| 187 | + ... |
| 188 | + } |
190 | 189 |
|
191 | 190 | private: |
192 | 191 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight |
|
198 | 197 | bool is_moving; |
199 | 198 | vec3 center_vec; |
200 | 199 |
|
201 | | - point3 center(double time) const { |
| 200 | + point3 sphere_center(double time) const { |
202 | 201 | // Linearly interpolate from center1 to center2 according to time, where t=0 yields |
203 | 202 | // center1, and t=1 yields center2. |
204 | | - return center0 + time*center_vec; |
| 203 | + return center1 + time*center_vec; |
205 | 204 | } |
206 | 205 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ |
207 | 206 | }; |
|
239 | 238 |
|
240 | 239 | </div> |
241 | 240 |
|
242 | | -<div class='together'> |
243 | | -We need to implement the new `interval::contains()` method mentioned above: |
244 | | - |
245 | | - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ |
246 | | - class interval { |
247 | | - public: |
248 | | - ... |
249 | | - bool contains(double x) const { |
250 | | - return min <= x && x <= max; |
251 | | - } |
252 | | - ... |
253 | | - }; |
254 | | - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
255 | | - [Listing [interval-contains]: <kbd>interval.h</kbd> interval::contains() method] |
256 | | - |
257 | | -</div> |
258 | | - |
259 | 241 |
|
260 | 242 | Tracking the Time of Ray Intersection |
261 | 243 | -------------------------------------- |
|
4198 | 4180 | (accessed MMM. DD, YYYY) |
4199 | 4181 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
4200 | 4182 |
|
4201 | | - ### MLA: |
| 4183 | + ### MLA |
4202 | 4184 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
4203 | 4185 | Ray Tracing: The Next Week. raytracing.github.io/books/RayTracingTheNextWeek.html |
4204 | 4186 | Accessed DD MMM. YYYY. |
|
0 commit comments