Subject: | DistanceToSegment() on empty segment |
Date: | Tue, 10 Jun 2014 17:10:43 +1000 |
To: | bug-Math-Geometry-Planar [...] rt.cpan.org |
From: | Kevin Ryde <user42_kevin [...] yahoo.com.au> |
DistanceToSegment() called on an empty segment results in a division by
zero. For example
use strict;
use Math::Geometry::Planar;
my $d = DistanceToSegment([[0,0], [0,0], [0,1]]);
print "$d\n";
prints
Illegal division by zero at /usr/share/perl5/Math/Geometry/Planar.pm line 773.
whereas I hoped it would print "1", for point 0,1 being a unit distance
away from 0,0.
I wonder whether this would be as easy as the diff below, doing the
division only when it's needed. Is that when the point is in between
the two line segment ends? At any rate d1>0 and d2>d1 ensures d2>0 and
so the division is good.
Message body is not shown because sender requested not to inline it.
Message body is not shown because sender requested not to inline it.