Skip to content

Commit

Permalink
Merge pull request #461 from RayTracing/1d-mc-integration
Browse files Browse the repository at this point in the history
Fix error in one dimensional MC integration
  • Loading branch information
hollasch committed Apr 10, 2020
2 parents 06b33f6 + b7a2b0f commit 41be1a3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ Change Log -- Ray Tracing in One Weekend
- Fix: Introduce `u`,`v` surface coordinates to `hit_record` (#441)
- Fix: Add highlight to new `hittable::bounding_box()` method (#442)

### _The Rest of Your Life_
- Fix: unitialized variable in first version of `integrate_x_sq.cc`
- Fix: remove unreferenced variables in several sample programs
- Fix: correct program computation of the integral of x^2 (#438)


----------------------------------------------------------------------------------------------------
# v3.0.1 (2020-03-31)
Expand Down
12 changes: 2 additions & 10 deletions books/RayTracingTheRestOfYourLife.html
Original file line number Diff line number Diff line change
Expand Up @@ -221,16 +221,14 @@
#include <stdlib.h>

int main() {
int inside_circle = 0;
int inside_circle_stratified = 0;
int N = 1000000;
double sum;
auto sum = 0.0;
for (int i = 0; i < N; i++) {
auto x = random_double(0,2);
sum += x*x;
}
std::cout << std::fixed << std::setprecision(12);
std::cout << "I = " << sum/N << '\n';
std::cout << "I = " << 2 * sum/N << '\n';
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[Listing [integ-xsq-1]: <kbd>[integrate_x_sq.cc]</kbd> Integrating $x^2$]
Expand Down Expand Up @@ -406,8 +404,6 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++

int main() {
int inside_circle = 0;
int inside_circle_stratified = 0;
int N = 1000000;
auto sum = 0.0;
for (int i = 0; i < N; i++) {
Expand Down Expand Up @@ -439,8 +435,6 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++

int main() {
int inside_circle = 0;
int inside_circle_stratified = 0;
int N = 1000000;
auto sum = 0.0;
for (int i = 0; i < N; i++) {
Expand Down Expand Up @@ -484,8 +478,6 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++

int main() {
int inside_circle = 0;
int inside_circle_stratified = 0;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
int N = 1;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
Expand Down

0 comments on commit 41be1a3

Please sign in to comment.