This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Projects a sphere with the given radius and distance onto a unit sphere at | |
* the origin, creating a spherical cap. Returns the angular radius of the cap, | |
* as well as its surface area as a fraction of the total solid angle. | |
*/ | |
void sphereCap(float radius, float distance, out float angularRadius, out float solidAngleFrac) { | |
float apparentRadius = radius/distance; | |
angularRadius = asin(apparentRadius); | |
solidAngleFrac = 0.5 - sqrt(1.0 - apparentRadius)*0.5; | |
} |