|
Welzl's Minimum Sphere Algorithm Demystified
The tester and the source codeAn implementation of the algorithm for 2D circles is given in the form of a simple Java-based tester. The tester provides a way for us to see the algorithm in action and see simple statistics about the number of point tests made (total iterations) and the number of restarts (m) of the algorithm. To run it, issue the following command in the directory containing the JAR file: > java -jar WelzlSphere.jar(Assuming you have your PATH environment variable set to point to java.exe) To use the tester, input the number of input points wanted and click 'Generate'. This will generate that amount of points in random locations and display them. Once points are randomized, 'Create Sphere' can be used to initiate the sphere generation. The sphere is then displayed on screen along with the points. Once a sphere is created the algorithm statistics appear in the status bar and are left there until a new sphere is created. The tester supports a maximum number of 10000 points. The number is chosen arbitrarily in the code. In terms of the source code – It is a very simple implementation and not production code. Aside for a circle class that supports construction of circles from various amounts of points there are no custom classes to make the code simpler (a lack of a simple vector class meant some calculations are just inlined). Some more notes:
ConclusionSpheres can be a great bounding volume in collision detection and are generally great geometric entities. The algorithm described here (Welzl 1991) is an efficient approach at computing the minimum enclosing sphere of a set of points, in real time. True, spheres and other bounding volumes can be computed in a pre-processing step but the need for a good real-time algorithm still exists (and it also helps to speed up pre-processing, whether the algorithm runs when loading a scene or when an external tool creates the bounding volume). References1. [Welzl91] - Smallest enclosing disks (balls and ellipsoids) "New Results and New Trends in Computer Science", (H. Maurer, Ed.), Lecture Notes in Computer Science 555 (1991) 359-370. 2. [Eberly03] - Geometric Tools for Computer Graphics by Philip J. Schneider and David H. Eberly, The Morgan Kaufmann Series in Computer Graphics and Geometric Modeling Copyright © 2003 by Elsevier Science (USA), Philip J. Schneider, and David H. Eberly
|