Commit 0ce5b90
committed
Corrected sphere UV coordinates
Fixed in text and code. This addresses the following problems:
- Confusion between UV space and texture image space. There were places
that assumed Y/V grows, down, others where Y/V grow upwards. Correct
UV coordinates have Y/V growing upwards, as in regular 2D Cartesian
coordinates. The V coordinate is flipped for texture-map lookup, left
alone for all other coordinate uses.
- The Y and Z coordinates were confused in several equations.
- The text had Y = sin(theta), where it should have been
Y = -cos(theta).
- There was nothing in the text to explain the rearrangment of atan2()
arguments in order to get a continuous 0->2pi return value. I
introduced the equivalence formula to get continuous return values.
- get_sphere_uv() was in sphere.h for book 2, but hittable.h for book 3.
This change also moves the function to sphere.h for book 3.
- get_sphere_uv() moved to be a private static method on class sphere.
- I am used to (and therefore prefer) phi corresponding to latitude, and
theta corresponding to longitude, where the text and code flip these
two angles. In a quick search of definitions, it looks like this is
yet another case of competing conventions with both sides roughly
equal in size. Thus, no clear winner, so I'm leaving this as is.
Resolves RayTracing#5331 parent 7a396c0 commit 0ce5b90
File tree
5 files changed
+89
-40
lines changed- books
- src
- TheNextWeek
- TheRestOfYourLife
5 files changed
+89
-40
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1148 | 1148 | | |
1149 | 1149 | | |
1150 | 1150 | | |
1151 | | - | |
1152 | | - | |
1153 | | - | |
1154 | | - | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
1155 | 1159 | | |
1156 | 1160 | | |
1157 | 1161 | | |
1158 | 1162 | | |
1159 | 1163 | | |
1160 | 1164 | | |
1161 | | - | |
1162 | | - | |
| 1165 | + | |
| 1166 | + | |
1163 | 1167 | | |
1164 | | - | |
1165 | | - | |
1166 | | - | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
1167 | 1174 | | |
1168 | 1175 | | |
1169 | 1176 | | |
1170 | | - | |
1171 | | - | |
1172 | | - | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
1173 | 1180 | | |
1174 | | - | |
| 1181 | + | |
1175 | 1182 | | |
1176 | 1183 | | |
1177 | 1184 | | |
1178 | | - | |
1179 | | - | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
1180 | 1196 | | |
1181 | | - | |
| 1197 | + | |
| 1198 | + | |
1182 | 1199 | | |
1183 | | - | |
| 1200 | + | |
1184 | 1201 | | |
1185 | 1202 | | |
1186 | 1203 | | |
1187 | | - | |
1188 | | - | |
| 1204 | + | |
| 1205 | + | |
1189 | 1206 | | |
1190 | 1207 | | |
1191 | | - | |
1192 | | - | |
1193 | | - | |
1194 | | - | |
1195 | | - | |
1196 | | - | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
1197 | 1226 | | |
1198 | 1227 | | |
1199 | 1228 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
35 | 51 | | |
36 | 52 | | |
37 | 53 | | |
| |||
43 | 59 | | |
44 | 60 | | |
45 | 61 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | 62 | | |
55 | 63 | | |
56 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | 21 | | |
29 | 22 | | |
30 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
38 | 54 | | |
39 | 55 | | |
40 | 56 | | |
| |||
64 | 80 | | |
65 | 81 | | |
66 | 82 | | |
| 83 | + | |
67 | 84 | | |
68 | 85 | | |
69 | 86 | | |
| |||
0 commit comments