in reply to perl module or code for calculating the shortest distance between a line and a point (vector linear algebra)

Use some vector manipulation package as for instance Math::Vector::Real (that I have just uploaded to CPAN!):
use Math::Vector::Real; my $l0 = V(?, ?); my $l1 = V(?, ?); my $p = V(?, ?); my $u = $l1 - $l0; $u /= abs($u); my $n = $p - $l0; $n -= ($n * $u) * $u; printf "distance is %d\n", abs($n);
  • Comment on Re: perl module or code for calculating the shortest distance between a line and a point (vector linear algebra)
  • Download Code