mmp / pbrt-v2

Source code for the version of pbrt described in the second edition of "Physically Based Rendering"
http://pbrt.org
990 stars 343 forks source link

Partial derivatives for Disk. #46

Closed ghost closed 9 years ago

ghost commented 9 years ago

The derivation of partial derivatives for Disk is skipped in the textbook, so I did it by myself and unfortunately got different partial derivatives from the one implemented in disk.cpp.

This pull request contains my partial derivatives for Disk in shapes/disk.cpp and 3 test cases in main/pbrt.cpp. After compiling the source code the tests can be run simply by typing:

./bin/pbrt

(Assume the current directory is src)

Below are the ouput on my laptop(Ubuntu 14.04): The old method: analytical dpdu: (0, 2.35619, 0) analytical dpdv: (-1.5, 0, 0) du: 0.000212207 dv: -3.57628e-07 numerical dpdu: (0, 4.71239, 0) du: 0 dv: -0.00100005 numerical dpdv: (-1, -0, -0) p2: (1.501, 0.001, 1) p1 + dpdu * du + dpdv * dv: (1.5015, 0.000499667, 1) relative error: 50.0435%

My method: analytical dpdu: (0, 4.71239, 0) analytical dpdv: (-1, -0, -0) du: 0.000212207 dv: -3.57628e-07 numerical dpdu: (0, 4.71239, 0) du: 0 dv: -0.00100005 numerical dpdv: (-1, -0, -0) p2: (1.501, 0.001, 1) p1 + dpdu * du + dpdv * dv: (1.501, 0.000999334, 1) relative error: 0.0534819%

mmp commented 9 years ago

Nice find--thanks!