
Post by fractallambda on Jul 8, 2021 20:48:52 GMT
First, thanks Jamis for the awesome book! Having a blast going through it.
Thought I'd raise this here regarding the sphere normal tests on Page 80 of the paper copy, section "Transforming Normals".
The values quoted in the tests are not very precise and my tests failed to pass.
Specifically, the tests as specified
Scenario: Computing the normal on a translated sphere Given s ← sphere() And set_transform(s, translation(0, 1, 0)) When n ← normal_at(s, point(0, 1.70711, 0.70711)) Then n = vector(0, 0.70711, 0.70711)
Scenario: Computing the normal on a transformed sphere Given s ← sphere() And m ← scaling(1, 0.5, 1) * rotation_z(π/5) And set_transform(s, m) When n ← normal_at(s, point(0, √2/2, √2/2)) Then n = vector(0, 0.97014, 0.24254)
In particular, the first test is not a point on the sphere. (quick check: √ (0.70711^2 + 0.70711^2) != 1.0
It does work within the book's tolerance of 0.00001, but I'm using a stricter comparison and my tests failed. For others who come across this issue, I recommend changing the tests to the following:
Scenario: Computing the normal on a translated sphere Given s ← sphere() And set_transform(s, translation(0, 1, 0)) When n ← normal_at(s, point(0, 1+√2/2, √2/2)) Then n = vector(0, 1/√2, 1/√2)
Scenario: Computing the normal on a transformed sphere Given s ← sphere() And m ← scaling(1, 0.5, 1) * rotation_z(π/5) And set_transform(s, m) When n ← normal_at(s, point(0, √2/2, √2/2)) Then n = vector(0, 0.970142500,0.242535625)
Which worked for me.
A quick check can show the difference in accuracy:
>>> x,y = 0.970142500,0.242535625 >>> x*x+y*y 0.9999999997003907 >>> a,b = .97014, 0.24254 >>> a*a+b*b 0.9999972711999999

