Skip to content

Commit ec8b43e

Browse files
trevordblackhollasch
authored andcommitted
Book 3 review, Chapters 1-3, responding to feedback
1 parent 026408c commit ec8b43e

File tree

6 files changed

+89
-85
lines changed

6 files changed

+89
-85
lines changed

books/RayTracingTheRestOfYourLife.html

Lines changed: 80 additions & 76 deletions
Large diffs are not rendered by default.

src/TheRestOfYourLife/cos_cubed.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ int main() {
3838
}
3939

4040
std::cout << std::fixed << std::setprecision(12);
41-
std::cout << "PI/2 = " << pi/2 << '\n';
42-
std::cout << "Estimate = " << sum/N << '\n';
41+
std::cout << "PI/2 = " << pi / 2.0 << '\n';
42+
std::cout << "Estimate = " << sum / N << '\n';
4343
}

src/TheRestOfYourLife/cos_density.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ int main() {
3434
}
3535

3636
std::cout << std::fixed << std::setprecision(12);
37-
std::cout << "PI/2 = " << pi/2 << '\n';
38-
std::cout << "Estimate = " << sum/N << '\n';
37+
std::cout << "PI/2 = " << pi / 2.0 << '\n';
38+
std::cout << "Estimate = " << sum / N << '\n';
3939
}

src/TheRestOfYourLife/estimate_halfway.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ int main() {
3434
std::vector<sample> samples;
3535
for (int i = 0; i < N; i++) {
3636
// Get the area under the curve
37-
auto x = random_double(0,2 * pi);
37+
auto x = random_double(0, 2*pi);
3838
auto sin_x = sin(x);
39-
auto p_x = exp(-x/ (2 * pi)) * sin_x * sin_x;
39+
auto p_x = exp(-x / (2*pi)) * sin_x * sin_x;
4040
sum += p_x;
4141
// store this sample
4242
sample this_sample = {x, p_x};

src/TheRestOfYourLife/integrate_x_sq.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <stdlib.h>
1818

1919
double f(double d) {
20-
return 8.0 * pow(random_double(), 1./3.);
20+
return 8.0 * pow(d, 1.0/3.0);
2121
}
2222

2323
double pdf(double x) {
@@ -34,5 +34,5 @@ int main() {
3434
}
3535

3636
std::cout << std::fixed << std::setprecision(12);
37-
std::cout << "I = " << sum/N << '\n';
37+
std::cout << "I = " << sum / N << '\n';
3838
}

src/TheRestOfYourLife/sphere_importance.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ int main() {
3535
sum += f_d / pdf(d);
3636
}
3737
std::cout << std::fixed << std::setprecision(12);
38-
std::cout << "I = " << sum/N << '\n';
38+
std::cout << "I = " << sum / N << '\n';
3939
}

0 commit comments

Comments
 (0)