commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles <gil...@harfang.homelinux.org>
Subject Re: [Math] Allow empty "ConvexHull2D"
Date Mon, 01 Jun 2015 13:27:08 GMT
Hello.

On Mon, 01 Jun 2015 15:03:47 +0200, luc wrote:
> Le 2015-06-01 14:38, Gilles a écrit :
>> Hi.
>
> Hi Gilles,
>> I have a question regarding
>> public Region<Euclidean2D> createRegion() throws 
>> InsufficientDataException
>> in ConvexHull2D.
>> It throws the exception when the number of points is < 3.
>> One can imagine that rather than aborting it could return an "empty 
>> Region"
>> (which would seamlessly work with further operations on the Region).
>> What do you think?
>> Context: in the course of a program, a "valid" region can undergo 
>> successive
>> transformation until it is indeed impossible to compute the hull; it 
>> seems
>> that it would be interesting to not treat that as a hard-failure 
>> (warranting
>> an exception).
>
> I'm on the fence on this. The exception is advertised right at the 
> the top
> interface level (ConvexHull in o.a.c.m.geometry.hull package) and
> clearly intended
> to cover this case. An empty region could be expected from computing
> the hull of n >= 3 aligned points, but n < 3 points is something
> different to me.

This is how I get the "Region" in my program:

    final ConvexHullGenerator2D hullGen = new MonotoneChain(false);
    final ConvexHull2D hull = hullGen.generate(data);
    final Region<Euclidean2D> hullRegion = hull.createRegion();

So, I note that "generate" did not raise an exception whereas the 
computation
request could be deemed invalid.  Then "createRegion" raises an 
exception...
Something looks wrong here: if the "hull" instance is valid (from a 
programming
perspective), then "hullRegion" should be valid too (i.e. "empty").

Assuming that you don't want to change the existing code, how can I 
create an
empty region?  Is there a singleton instance to represent the concept?

Thanks,
Gilles

>
> best regards
> Luc


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message