# Edit Create an Image Page: Bounding Volumes

To create an image page, simply complete the form below and then hit the 'Save Page' button at the bottom of the form. As you complete the form, remember that one of the main goals of the Math Images Project is to provide explanations of the images on our site at various levels, so that everyone can understand some of the math behind the images. Try to complete the form as fully as possible, but remember that other users will have the opportunity to add more information to your image pages in the future. Also, please note that by contributing to the Math Images Project, you agree to comply to the guidelines as stated in our general disclaimer.

As always, thank you for your contributions! --The Math Images Project

If you need help filling out this page, please consult our Help sections: Want to Contribute and Math Resources.

Note: * Indicates a required field.

Please note: When you are filling in the below explanations, you should feel free to use standard wikitext.

 Image Title*: Upload a Math Image A box bounding the Stanford Bunny mesh. A bounding volume in computer graphics is a shape that encloses one or more objects. The shape should be the tightest fit to the set of objects. Many figures are complicated and have hundreds of vertices, which make up their shapes. By bounding them in simple geometric shapes, it would lower the computational cost when detecting collisions between multiple objects and checking for intersections in ray tracing. There can be multiple levels of bounding volumes for a set of objects, e.g. smaller bounding boxes for different parts of a human figure (a box for the head and another for the torso, etc.) in a bigger box that bounds the whole body. {{Hide|1={{#ev:youtube|qHnpKI1ejQg}} }} Ray tracing is a method of generating a graphical image on the screen. It is used display simulated optical effects such as shadows, reflection and refraction. Light rays are cast onto the scene and the program must test if the rays are intersecting the object in the scene. Depending on the surface of the object, the rays would determine how it would be rendered. Because the program must determine if the rays intersect the object’s vertices, the computational cost can be expensive. The bounding box or any simple geometric volume that is a tight fit to the object lowers the computational cost. With the box, the rays would not trace points that are not in the box, since that would mean the object does not exist outside of it.

The same concept applies to collision detection. With bounding volumes, there is a hierarchy of tests for intersections of vertices and edges. The program can quickly decide if the object are near each other before testing for the vertices of the object. For example, if there are two bounding spheres, and they are across the room from each other. The program can detect that from the center of one sphere to the other is bigger than both of their radii combined. If the distance is smaller, then we can compare the vertices to determine if they colliding. The first step saves computational power, since the vertices do not have to test against each other until the two objects are close together.
== Different Bounding Volumes == [[Image:Axis_aligned_bounding_box.png‎|Axis aligned bounding box|thumb|80px|left]] [[Image:Non-aligned_bounding_box.png|Oriented bounding box|thumb|80px|right]] [[Image:Sphere_bounding_bunny.png|Bounding sphere|thumb|95px|right]] '''Bounding Box'''
It is a cuboid that contains the object. It is best for shapes that are shaped like rectangles or squares. One use of this shape is to detect collision of cup on a table. Sometimes, an axis aligned bounding box is not the tightest fit for the shape (figure on the left), and the the tighter fit is a non-axis aligned box or an oriented bounding box (figure on the right). An axis aligned bounding box is easier to implement and test, but if the object is rotated, an oriented bounding box would have an advantage in computing cost.

'''Bounding Sphere'''
It is a sphere that encapsulate the object, like a hamster in a hamster ball. The challenge with this shape is finding the tightest fit. The images below (under "show more") show a bunny in a sphere, but there is a lot of empty space in the sphere because it was created using the box as guide, i.e. the sphere is bounding the box. The radius of the sphere was calculated using the distance from the center to a corner in the cuboid.
{{Hide|1= [[Image:Bounding_sphere_large.png|530px]]
[[Image:Bounding_box_sphere_large2.png|530px]] }} To find a tighter fitting sphere, a better method would be to compare the center point of the object to the vertices of the object, and the longest distance would be the radius. The challenging part of this method is finding where the center should be. Below (under "show more"), the center of the sphere is the center of the cubiod, and that point is compared with all the vertices on the bunny. The second image shows that the sphere is no longer bounding the red bounding box.
{{Hide|1= [[Image:Tighter_bounding_sphere.png|530px]]
[[Image:Tighter_bounding_sphere-2.png|530px]] }} [[Image:Arbitrary convex region.png‎|An arbitrary convex bounding volume|thumb|120px|left]]Even though the sphere above is a tighter fit, it is still not the tightest. Finding the correct center point for the sphere would get the tightest sphere. There are many different methods to finding the point closest to a tight fitting sphere, but there is no one correct way that works for any figure.

'''Other Bounding Volumes'''
Bounding volumes can be any shape. Other frequently used ones are ellipsoids, which are like flattened spheres, and cylinders. Ellipsoids are used for objects like fighter jets or figures where the length of the sides are not similar and would leave a lot of empty space if bounded by a sphere. Cylinders are typically used to bound an upright human or any humanoid figure. Besides the common bounding shapes, a convex hull, which is an arbitrary convex volume that contains the object(s) in the smallest space, can also be used. I used OpenGL with C++. Most of the code, available under [http://mathforum.org/mathimages/index.php/Bounding_Volumes#Related_Links Related Links], belongs to [[User:Cutler]]. Algebra Analysis Calculus Dynamic Systems Fractals Geometry Graph Theory Number Theory Polyhedra Probability Topology Other None Algebra Analysis Calculus Dynamic Systems Fractals Geometry Graph Theory Number Theory Polyhedra Probability Topology Other None Algebra Analysis Calculus Dynamic Systems Fractals Geometry Graph Theory Number Theory Polyhedra Probability Topology Other [[Image:Frosted glass dragon.jpg|A frosted glass dragon Jensen, Henrik W. (2001). http://graphics.ucsd.edu/~henrik/images/raytrace.html. Ray Tracing.|thumb|150px|left]] [[Image:Cloth_collision.png|Cloth-to-cloth collision on her shirt. Baraff, David. (2003). http://graphics.pixar.com/library/UntanglingCloth/index.html. Untangling Cloth.|thumb|140px|right]] Ray tracing and collision detection is used in animation for films, special effects and video games. Although ray tracing can create photo-realistic looking images, like the image to the left by Henrik Wann Jensen, it is not efficient for real-time applications, like video games, because it is computationally expensive, which would need time to render. However accurate collision detection is important in video games, especially since modern games are becoming more realistic. For example, people are not supposed to walk through walls, so the character could only be a certain distance with the wall before the characters becomes absorbed by it. Bounding volumes are useful with collisions detection by putting a hierarchy of bounding volumes around the object. However, self-colliding objects, like cloth, is a more difficult problem.

The image is a visual of a bounding on an object. [http://code.google.com/p/math-images/source/browse/#svn%2Ftrunk%2Fpage_code%2Fbounding_volumes Code of the Images]
[http://www.mvps.org/directx/articles/using_bounding_spheres.htm Collision Detection by Robert Dunlop]