# Cosine weighted mapping explanations

This topic is 1009 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi,

I'm currently working with some algorithmes that required sampling a sphere using various mapping distributions. I'm using a Hammersley sequence to do so, which gives me 2 values in the [0, 1] range, and then I use those values to convert to a spherical coordinate, and finally convert to a cartesian coordinate. My source is this page : http://holger.dammertz.org/stuff/notes_HammersleyOnHemisphere.html

Now what I'm having trouble with is the mapping from the hammersley values to spherical. In the linked page, there are 2 mappings : uniform and cosinus. I perfectly understand the math behind the uniform mapping (e.g. I can find the equation to go from hammersley to cartesian on a piece of paper) but I'm totally lost when I look at the cosine weighted mapping.

I can't understand the signification of the square root, and where does it come from. And I can't find any explanation on the web has to how to obtain this equation. I kind of understand the principle of the cosine weighted mapping, but I can't take a piece of paper and write the equations to go from hammersley to the final cartesian coordinate using this mapping.

Is there anyone here that knows where does this square root comes from and cares explaning it to me ?

Thanks in advance for any help !

##### Share on other sites

Ok, first post in many years, and I managed to finally find the answer minutes after asking the question (I've been trying to find it for 1 whole day before that) and it's so simple I'm a bit ashamed ^^'

Anyway, if anyone stumble onto this post with the same question, here is a quick explanation.

    ^
|
1-u |------/
|     /
|    /
|   / H
|o /
| /
|/___________>


Forgive my poor ascii art, but it's easier to understand this way ^^'
Here, o is the theta angle. Since we're sampling on a unit sphere, H is always of length 1. This leads to cos(o) = 1-u for the uniform mapping, all good.

Now for the cosine weighted one, H is no longer of length 1 (that's what I had wrong) : its length is what's weighted by the cosine ! So in fact : |H| = cos(o)
And now, we have the following : cos(o) = (1-u) / |H| = (1-u) / cos(o)
And this leads to cos(o) = sqrt(1-u)

One day to come up with that ... I feel a bit dumb, but still glad to finally understand this completely ^^'

Edited by intyuh