The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Math::Vector::Real::Polyline - Algorithms related to polylines.

SYNOPSIS

  use Math::Vector::Real::Polyline;

  my $poly1 = Math::Vector::Polyline->new(@vectors1);
  my $poly2 = Math::Vector::Polyline->new(@vectors2);

  my $d = $poly1->dist_to_polyline(@poly2);
  printf "The distance between %s and %s is %f",
         $poly1, $poly2, $d;

DESCRIPTION

This module implements several algorithms related to polygonal chains or polylines.

Note that the module can handle polylines in spaces of any dimension (not just 2D).

API

$p = Math::Vector::Polyline->new(@vectors)

Creates a new polyline object.

$d2 = $p->dist2_to_point($v)

Returns the square of the distance from the polyline to the given point.

$d2 = $p->dist2_to_segment($a, $b)

Returns the square of the distance from the polyline to the segment with the given vertices.

$d2 = $p->dist2_to_polyline($p1)

Returns the square of the distance between both polylines.

SEE ALSO

Math::Vector::Real.

Polygonal Chain at Wikipedia.

The StarOverflow post that started it.

COPYRIGHT AND LICENSE

Copyright (C) 2017 by Salvador Fandiño <sfandino@yahoo.com>.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.24.1 or, at your option, any later version of Perl 5 you may have available.