Special Center of Points

Started by
2 comments, last by NullStar 5 years, 7 months ago

I'm trying to generate a single bounding sphere for a collection of rigid body shapes. The shapes are limited to sphere, capsule, cylinder, and box. I am currently simplifying the box into a sphere, and the cylinder into a capsule to reduce stress. So as far as what I need to generate a bounding sphere, I can essentially represent each of these shapes with one or two spheres (capsule becomes its two contained spheres).

Currently, I am iterating the spheres, and for each one, combining the result with the new sphere by computing a container sphere of both. The new center is half-way between the extents of both spheres (center = (a.pos + -a.radius + b.pos + b.radius) / 2 ), and the new radius is half of { distance + a.radius + b.radius }.

I've done a little research into how complex it can be to find the spacial center of an arbitrary cluster of points. So I'm wondering if this will work as efficiently (volume space wise) as using one of these functions? If I iterate my spheres and generate the container sphere for each situation, will the end result be efficient as far as only being large enough to encapsulate all of the internal spheres? Or will its center be offset in some weird direction because of the order I iterated them?

My game code is a heavy construction mess at the moment, or I would just test the code under a bunch of situations to see how well it does. If anyone has ever tried this, or can already see that it won't work well, I appreciate the insights.

Thanks!

Advertisement

Consider a plane version of this problem, and we'll only try to encapsulate points (i.e., spheres of radius 0). Take three points at the vertices of an equilateral triangle. Draw what the iterative procedure would do on a piece of paper, and you'll notice how the resulting circle is needlessly large.

You may want to read the brief description of a few algorithms here: https://en.wikipedia.org/wiki/Bounding_sphere
 

 

Thank you for pointing that out. You just saved me a ton of time. Back to the research.

This topic is closed to new replies.

Advertisement