commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Neidhart <>
Subject [math][MATH-749] Convex hull
Date Sun, 26 Jan 2014 22:52:00 GMT

finally, I have a patch ready to be included for MATH-749.
What took me so long was some confusion about the type system in the
geometry package.

It is actually quite difficult to do some generic algorithm code by only
specifying the relevant space type (e.g. Euclidean2D).

The Vector/Point interface does not allow access to its components, thus
any algorithm that needs access to them either has to cast, or
explicitly specify the type.

I decided now to come up with the following:

There is a generic interface for convex hull generators:

public interface ConvexHullGenerator<S extends Space, V extends Vector<S>>

and currently one concrete implementation for the euclidean 2d space:

public class GrahamScan2D<V extends Vector2D> implements
ConvexHullGenerator<Euclidean2D, V>

The reason GrahamScan2D still has a generic type parameter is because I
wanted to cover also the use-case of people extending Vector2D, although
I am not sure if this is realistic/useful. We may also change this to:

public class GrahamScan2Dimplements ConvexHullGenerator<Euclidean2D,

Ideally, the Vector interface would have a method

double getComponent(int dimension)


double[] getData()

to provide access to the components of the vector and I would like to
discuss this for 4.0 considering the other uses of Vector.

Anyway, I would be grateful if somebody could review the patch. If the
general interface is accepted, I plan to add more implementations.



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message