Brian
New Member
Posts: 3
|
Post by Brian on Jul 29, 2019 1:57:33 GMT
I just submitted an error to the Pragmatic Bookshelf's Errata page for this book, and I thought I would share it here too in case anyone is trying to figure out why their test isn't passing.
The suspected error is on page 95 of the paper book and my error report follows:
-- Brian
|
|
|
Post by Richard Moss on Jul 29, 2019 5:40:40 GMT
Hello,
I can't speak for your case but there were a number of times I got output I wasn't quite expecting, often this was because I'd missed a minus sign next to a number or in one case lack of parenthesis meant a calculation came out wrong or I misread the instructions and implemented the wrong thing. As this test passed for me absolutely fine (as have all the others so far; I'm up to Chapter 16 currently) nor is there any other mention on this forum of that test from users who have progressed beyond it, there's possibly an error in your code rather than an error in the book.
|
|
Brian
New Member
Posts: 3
|
Post by Brian on Jul 29, 2019 10:33:23 GMT
Hello Richard, I have also had similar experiences: hunting for a missing minus sign, or some other typo in my code. However, in this case, after looking for such a typo for quite a while, I decided to try the next test ("Scenario: Shading an intersection from the inside"), and it passed. Since both those tests are so similar, I would have expected that both would either pass or fail. With one passing and one failing, I started to suspect that the problem might not be in my code. I then opened up Inkscape and drew three rectangles: - I filled the first rectangle with the colour of the object's material: color(1.0, 0.2, 1.0) = RGB(255, 51, 255) = magenta,
- I filled the second rectangle with the expected colour, from the book's test: color(0.38066, 0.47583, 0.2855) = RGB(97, 121, 73) = dark green (similar to the green of one of the spheres in the banner at the top of this forum - the one just to the right of the gap in the centre of the banner), and
- I filled the third rectangle with the actual colour, the colour that my code comes up with: color(0.47582649135129296, 0.09516529827025859, 0.47582649135129296) = RGB(121, 24, 121) = a purplish colour, or, with a little imagination, a shaded magenta colour.
I considered the fact that my code that creates the "default_world" may be assigning the wrong colour to the "first object" in this default world, so I made a quick change to the colour of that object and, as expected, the test "Scenario: The default world" from p. 92 failed. Now, I'm reasonably certain that my object is the correct colour (magenta), and it makes sense to me that the shade_hit function would return a darker shade of that colour and not a dark green. I'm entirely open to the fact that I may have made an error somewhere else in my code - I am working fairly quickly through this - but if I did, I can't find my error. Thank you for any feedback, -- Brian
|
|
|
Post by Jamis on Jul 29, 2019 14:10:21 GMT
Hello Brian, I definitely don't discount that you've found an error in the book! I can't verify right now, though, as the laptop with my code and tests is currently en route to Apple due to a battery recall, but I'll check as soon as it gets back. Until then, if anyone else can take a close look at their code and compare it with Brian's results, maybe we can resolve the discrepancy sooner! - Jamis
|
|
|
Post by sbehnke on Jul 29, 2019 15:16:25 GMT
I have to disagree that there is an error in the expected values. I got the exact values that Jamis got in my unit test. There were some unit tests I had where there was not enough precision, but this wasn't one of them.
|
|
Brian
New Member
Posts: 3
|
Post by Brian on Jul 29, 2019 21:13:37 GMT
Well, it seems that the problem is in fact with my code. The "first object" in the the default world is in fact (0.8, 1.0, 0.6), a lime green colour (not magenta), which makes the shaded colour a dark green.
When I wrote the test for the default world, I, for some inexplicable reason, was testing the first object for a magenta colour, and not the lime green colour from the book. I wrote the production code to satisfy that (miss-typed) test.
When troubleshooting my code, I had suspected that my object might be the wrong colour and verified the colour by changing it and running the tests; I hadn't considered that my object might be the wrong colour because I had an error in the test.
Thank you to everyone, -- Brian
|
|
|
Post by Jamis on Jul 29, 2019 21:44:39 GMT
Glad you found it!
|
|
|
Post by krotus on Apr 2, 2020 3:58:26 GMT
The issue I'm having is with the second test on the aforementioned Page 95 of the book, "Shading an intersection from the inside".
I currently have the default world set up with both spheres being R = 0.8, G = 1.0, B = 0.6 because page 92 only gives us the setting for one material but 2 spheres.
So, am I missing something? Are the rest of you who have passed this point getting R = 0.90498, G = 0.90498, B = 0.90498 using the same material settings for the second sphere as you did in the first sphere where you got the values of R = 0.38066, G = 0.47583, B = 0.2855 in the previous test of "Shading an intersection"?
Looking at the results in the book, one would assume that the second sphere has a different material than the first sphere, one in which the RGB values are all the same, meaning it's somewhere between Black and White and probably has different ambient and diffuse values.
|
|
fremag
Junior Member
Posts: 73
|
Post by fremag on Apr 2, 2020 8:32:51 GMT
My tests give the correct values given in the book. My spheres don't have the same material. I use a default material (color white, ambient=0.1, diffuse=0.9, specular=0.9, shininess=200) for the second sphere. This default material is defined page 85.
The default world has a default light but in the test, it is replaced by another one, are you sure you don't have two lights ?
|
|
|
Post by krotus on Apr 2, 2020 18:25:51 GMT
My tests give the correct values given in the book. My spheres don't have the same material. I use a default material (color white, ambient=0.1, diffuse=0.9, specular=0.9, shininess=200) for the second sphere. This default material is defined page 85. The default world has a default light but in the test, it is replaced by another one, are you sure you don't have two lights ?
Thanks! I had altered the default setting at some point and forgot to change it back.
|
|