Skip to content

Commit e3a1d4e

Browse files
committed
camera::get_ray() is const
Also changes member variables from public to private. Resolves #446
1 parent edce6b9 commit e3a1d4e

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

books/RayTracingInOneWeekend.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,11 +1320,11 @@
13201320
origin = point3(0.0, 0.0, 0.0);
13211321
}
13221322

1323-
ray get_ray(double u, double v) {
1323+
ray get_ray(double u, double v) const {
13241324
return ray(origin, lower_left_corner + u*horizontal + v*vertical - origin);
13251325
}
13261326

1327-
public:
1327+
private:
13281328
point3 origin;
13291329
point3 lower_left_corner;
13301330
vec3 horizontal;
@@ -2577,11 +2577,11 @@
25772577
}
25782578
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
25792579

2580-
ray get_ray(double u, double v) {
2580+
ray get_ray(double u, double v) const {
25812581
return ray(origin, lower_left_corner + u*horizontal + v*vertical - origin);
25822582
}
25832583

2584-
public:
2584+
private:
25852585
point3 origin;
25862586
point3 lower_left_corner;
25872587
vec3 horizontal;
@@ -2668,11 +2668,11 @@
26682668
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
26692669
}
26702670

2671-
ray get_ray(double s, double t) {
2671+
ray get_ray(double s, double t) const {
26722672
return ray(origin, lower_left_corner + s*horizontal + t*vertical - origin);
26732673
}
26742674

2675-
public:
2675+
private:
26762676
point3 origin;
26772677
point3 lower_left_corner;
26782678
vec3 horizontal;
@@ -2806,7 +2806,7 @@
28062806
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
28072807
}
28082808

2809-
ray get_ray(double s, double t) {
2809+
ray get_ray(double s, double t) const {
28102810
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
28112811
vec3 rd = lens_radius * random_in_unit_disk();
28122812
vec3 offset = u * rd.x() + v * rd.y();
@@ -2818,7 +2818,7 @@
28182818
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
28192819
}
28202820

2821-
public:
2821+
private:
28222822
point3 origin;
28232823
point3 lower_left_corner;
28242824
vec3 horizontal;

books/RayTracingTheNextWeek.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
vertical = 2*half_height*focus_dist*v;
139139
}
140140

141-
ray get_ray(double s, double t) {
141+
ray get_ray(double s, double t) const {
142142
vec3 rd = lens_radius * random_in_unit_disk();
143143
vec3 offset = u * rd.x() + v * rd.y();
144144
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
@@ -150,7 +150,7 @@
150150
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
151151
}
152152

153-
public:
153+
private:
154154
point3 origin;
155155
point3 lower_left_corner;
156156
vec3 horizontal;

src/common/camera.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class camera {
4545
vertical = 2*half_height*focus_dist*v;
4646
}
4747

48-
ray get_ray(double s, double t) {
48+
ray get_ray(double s, double t) const {
4949
vec3 rd = lens_radius * random_in_unit_disk();
5050
vec3 offset = u * rd.x() + v * rd.y();
5151
return ray(
@@ -55,7 +55,7 @@ class camera {
5555
);
5656
}
5757

58-
public:
58+
private:
5959
point3 origin;
6060
point3 lower_left_corner;
6161
vec3 horizontal;

0 commit comments

Comments
 (0)