Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Book 3.4: Sphere Importance Sampling #1500

Closed
rupsis opened this issue Apr 5, 2024 · 3 comments
Closed

Book 3.4: Sphere Importance Sampling #1500

rupsis opened this issue Apr 5, 2024 · 3 comments
Assignees
Milestone

Comments

@rupsis
Copy link
Contributor

rupsis commented Apr 5, 2024

Perhaps I'm just slow, but for Listing 16, the f() function took me a little while to figure out.

double f(const vec3& d) {
    auto cosine_squared = d.z()*d.z();
    return cosine_squared;
}

If I understand correctly, $cos(\theta)^2$ here is $(\cos(0^\circ) *z)^2$ (where Z is from the random_unit_vector)
and since $cos(0^\circ) = 1$ we're left with d.z()*d.z().

The text doesn't make that obvious. Perhaps (and very likely) the issue is me. But if my understanding is correct, maybe some clarification could be useful. A small attempt on my part:

image
@hollasch hollasch added this to the v4.0.0 milestone Apr 5, 2024
@hollasch
Copy link
Collaborator

hollasch commented Apr 5, 2024

Good point. I don't know if I would have made the connection myself. I would actually expound on this a bit further. Something like:

If the integrand is $\cos^2(\theta)$, and $\theta$ is the angle with the $z$ axis, then $\theta = 0$, and $\cos^2(0) = 1$.

I'm still missing where the $z$ comes in, though. Why is $\cos^2(\theta) = (\cos(0\deg)\cdot z)^2$?

@trevordblack? @petershirley?

@dimitry-ishenko
Copy link
Contributor

dimitry-ishenko commented Apr 15, 2024

@rupsis @hollasch I think you guys got this wrong. 😺

From scalar projection we know that projection of vector $a$ onto $b$ is equal to the length of $a$ multiplied by the cosine of angle $\theta$ between $a$ and $b$.

In our case we have random vector $d$ (of unit length) and from the chapter we know that " $\theta$ is the angle with the $z$ axis." Therefore we can say that projection of $d$ onto axis $z$ is equal $d_z = \lVert d \rVert \cos \theta = 1 \cdot \cos \theta$.

So, in our function $f(\theta, \phi) = \cos^2 (\theta)$ we can replace $\cos \theta$ with $d_z$ and get $f(\theta, \phi) = f(d) = {d_z}^2$.

@hollasch hollasch changed the title [Book 3] Sphere Importance Sampling Book 3.4: Sphere Importance Sampling Apr 19, 2024
rupsis added a commit that referenced this issue Apr 26, 2024
@hollasch
Copy link
Collaborator

See also #1536. Things are a bit muddy in this region of the text.

hollasch pushed a commit that referenced this issue May 8, 2024
@hollasch hollasch closed this as completed May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants