I’m trying to comprehend something that’s probably a lot easier than I think right now so hopefully someone might be able to help me understand what I describe below.
I know that a sphere is outside the view frustum if it’s completely behind at least one of the six frustum planes in 3D (left, right, bottom, top, near far). This is true for the circle with center c2 in the example below, which is completely outside left plane. The overlap test is simply done by inserting the center coordinates of the sphere into the plane equation to get the distance from the center to the plane and then comparing this with the radius of the sphere.
However, using this approach on the sphere with center c1 will give us a false positive since the test will tell us the sphere is inside both right and far plane (if seen from above). The solution is then to use a more exact overlap test by determining the distance from the spheres center to the corner of the view frustum that is closest to it. If this distance is greater than the radius, the sphere is outside the frustum etc.
What I don’t understand is what if we use this second approach, looking at the corners instead of the planes, on a sphere located like the one with center c3. Won’t the test will give us that the distance from the spheres center minus the radius is greater than 0 and thus outside of the viewing volume?
So If am given a set of rules for an orthographic view volume, i.e. 0 ≤ x ≤ 20, -5 ≤ 15, -5 ≤ z ≤ 18, and x,y,z-coordinates + radius of a sphere and told to determine whether the sphere is inside or outside it. How do I choose what method to use in order to really obtain the right answer?
In fact you need both:
first approach
.red
cross is on your black
segment you got intersection):
Implementation of 3 could be tricky so Here are two links:
http://www.realtimerendering.com/intersections.html http://www.geometrictools.com/Source/Intersection3D.html
where you can find Frustrum-Sphere intersection algo.
But geometrictools
implementation uses FindMinDistance
algo which is more complicated. You can examine their implementation (Wm5DistPoint3Frustum3.cpp
) and adapt it to itersection only.