Posted by lukabratzi
on 04 November 2011 - 08:21 AM
I'm working on implementing Welzl's algorithm for finding the minimal bounding sphere of a set of vertices. I'm getting some pretty huge bounding spheres though, which can't be right. I'm thinking that something must be wrong with how I'm calculating my sphere from either 3 points or from 4 points (possibly both are wrong). As far as I can tell, there's 4 different ways to build a sphere:
sphere from 1 point: Center is point, radius is 0
sphere from 2 points: Center is midpoint, radius is half distance
I've tried several methods for the 4 point sphere, here's the one that I've settled on: 4 point sphere method
Now when I expand a sphere, I take the support set (all points currently used to define the sphere, always less than 5) and the new point and test all possible permutations of the support set and the new point to find the minimal sphere. For instance, if my support set has 4 vertices then I first try all two point combinations of the support set and the new point, then all 3 point combinations and finally all 4 point combinations. I then replace/remove any necessary points from the support set and add the newpoint to the support set. I'm 99% sure that the logical flow of my algorithm is right, I believe I just have some grievous math error somewhere in my Sphere calculation routine.
Are there any better ways to calculate a minimal bounding sphere from 3 or 4 points?
Edit: Also, on the off chance that anyone needs to see my sphere calculation functions in order to help: