Top Description Fields Constructors Methods
org.apache.commons.math3.geometry.enclosing

public Class WelzlEncloser<S extends Space, P extends Point<S>>

extends Object
implements Encloser<S extends Space, P extends Point<S>>
Class Inheritance
All Implemented Interfaces
org.apache.commons.math3.geometry.enclosing.Encloser
Type Parameters
<S>
Space type.
<P>
Point type.
Imports
java.util.ArrayList, .List, org.apache.commons.math3.exception.MathInternalError, org.apache.commons.math3.geometry.Point, .Space

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 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

Modifier and TypeField and Description
private final SupportBallGenerator<S, P>
generator

Generator for balls on support.

private final double
tolerance

Tolerance below which points are consider to be identical.

Constructor Summary

AccessConstructor and Description
public
WelzlEncloser(final double
below which points are consider to be identical
tolerance
,
final SupportBallGenerator<S, P>
generator for balls on support
generator
)

Simple constructor.

Method Summary

Modifier and TypeMethod and Description
public EnclosingBall<S, P>
enclose(final Iterable<P>
points to enclose
points
)

Implements org.apache.commons.math3.geometry.enclosing.Encloser.enclose.

Find a ball enclosing a list of points.

private EnclosingBall<S, P>

Returns:

enclosing ball, for the extreme subset only
moveToFrontBall
(final List<P>
subset of extreme points
extreme
,
final int
number of extreme points to consider
nbExtreme
,
final List<P>
points that must belong to the ball support
support
)

Compute enclosing ball using Welzl's move to front heuristic.

private EnclosingBall<S, P>

Returns:

enclosing ball
pivotingBall
(final Iterable<P>
points to be enclosed
points
)

Compute enclosing ball using Gärtner's pivoting heuristic.

public P

Returns:

farthest point
selectFarthest
(final Iterable<P>
points to be enclosed
points
,
final EnclosingBall<S, P>
current ball
ball
)

Select the point farthest to the current ball.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

generatorback to summary
private final SupportBallGenerator<S, P> generator

Generator for balls on support.

toleranceback to summary
private final double tolerance

Tolerance below which points are consider to be identical.

Constructor Detail

WelzlEncloserback to summary
public WelzlEncloser(final double tolerance, final SupportBallGenerator<S, P> generator)

Simple constructor.

Parameters
tolerance:double

below which points are consider to be identical

generator:SupportBallGenerator<S, P>

generator for balls on support

Method Detail

encloseback to summary
public EnclosingBall<S, P> enclose(final Iterable<P> points)

Implements org.apache.commons.math3.geometry.enclosing.Encloser.enclose.

Doc from org.apache.commons.math3.geometry.enclosing.Encloser.enclose.

Find a ball enclosing a list of points.

Parameters
points:Iterable<P>

points to enclose

Returns:EnclosingBall<S, P>

enclosing ball

moveToFrontBallback to summary
private EnclosingBall<S, P> moveToFrontBall(final List<P> extreme, final int nbExtreme, final List<P> support)

Compute enclosing ball using Welzl's move to front heuristic.

Parameters
extreme:List<P>

subset of extreme points

nbExtreme:int

number of extreme points to consider

support:List<P>

points that must belong to the ball support

Returns:EnclosingBall<S, P>

enclosing ball, for the extreme subset only

pivotingBallback to summary
private EnclosingBall<S, P> pivotingBall(final Iterable<P> points)

Compute enclosing ball using Gärtner's pivoting heuristic.

Parameters
points:Iterable<P>

points to be enclosed

Returns:EnclosingBall<S, P>

enclosing ball

selectFarthestback to summary
public P selectFarthest(final Iterable<P> points, final EnclosingBall<S, P> ball)

Select the point farthest to the current ball.

Parameters
points:Iterable<P>

points to be enclosed

ball:EnclosingBall<S, P>

current ball

Returns:P

farthest point