java.lang.Object
org.apache.commons.math3.geometry.enclosing.WelzlEncloser<S,P>
- Type Parameters:
S
- Space type.P
- Point type.
- All Implemented Interfaces:
Encloser<S,
P>
public class WelzlEncloser<S extends Space,P extends Point<S>>
extends Object
implements Encloser<S,P>
Class implementing Emo Welzl algorithm to find the smallest enclosing ball in linear time.
The class implements the algorithm described in paper Smallest Enclosing Disks (Balls and Ellipsoids) by Emo Welzl, Lecture Notes in Computer Science 555 (1991) 359-370. The pivoting improvement published in the paper Fast and Robust Smallest Enclosing Balls, by Bernd Gärtner and further modified in paper invalid input: '<'a href=http://www.idt.mdh.se/kurser/ct3340/ht12/MINICONFERENCE/FinalPapers/ircse12_submission_30.pdf"> Efficient Computation of Smallest Enclosing Balls in Three Dimensions by Linus Källberg to avoid performing local copies of data have been included.
- Since:
- 3.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final SupportBallGenerator
<S, P> Generator for balls on support.private final double
Tolerance below which points are consider to be identical. -
Constructor Summary
ConstructorsConstructorDescriptionWelzlEncloser
(double tolerance, SupportBallGenerator<S, P> generator) Simple constructor. -
Method Summary
Modifier and TypeMethodDescriptionFind a ball enclosing a list of points.private EnclosingBall
<S, P> moveToFrontBall
(List<P> extreme, int nbExtreme, List<P> support) Compute enclosing ball using Welzl's move to front heuristic.private EnclosingBall
<S, P> pivotingBall
(Iterable<P> points) Compute enclosing ball using Gärtner's pivoting heuristic.selectFarthest
(Iterable<P> points, EnclosingBall<S, P> ball) Select the point farthest to the current ball.
-
Field Details
-
tolerance
private final double toleranceTolerance below which points are consider to be identical. -
generator
Generator for balls on support.
-
-
Constructor Details
-
WelzlEncloser
Simple constructor.- Parameters:
tolerance
- below which points are consider to be identicalgenerator
- generator for balls on support
-
-
Method Details
-
enclose
Find a ball enclosing a list of points. -
pivotingBall
Compute enclosing ball using Gärtner's pivoting heuristic.- Parameters:
points
- points to be enclosed- Returns:
- enclosing ball
-
moveToFrontBall
Compute enclosing ball using Welzl's move to front heuristic.- Parameters:
extreme
- subset of extreme pointsnbExtreme
- number of extreme points to considersupport
- points that must belong to the ball support- Returns:
- enclosing ball, for the extreme subset only
-
selectFarthest
Select the point farthest to the current ball.- Parameters:
points
- points to be enclosedball
- current ball- Returns:
- farthest point
-