Skip to content

Instantly share code, notes, and snippets.

@jcayzac
Created September 26, 2011 08:34
Show Gist options
  • Save jcayzac/1241863 to your computer and use it in GitHub Desktop.
Save jcayzac/1241863 to your computer and use it in GitHub Desktop.
Charles Bloom algorithm for sphere-cone intersection (simplified)
V = sphere.center - cone.apex_location
a = dotProduct(V, cone.direction_normal)
x = cone.cos * sqrt(dotProduct(V,V) - a*a) - a*cone.sin
if (abs(x) > sphere.radius) {
if (x < 0)
return 1; // Sphere is totally included in cone
else
return 0; // Sphere and cone don't intersect at all
}
else return -1; // Sphere is partially included in cone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment