NAME

Algorithm::Line::Lerp - 2D grid line drawing via linear interpolation

SYNOPSIS

use Algorithm::Line::Lerp 'line';

my $points = line( [0,0], [2,11] );
for my $p (@$points) { ...

DESCRIPTION

This module uses linear interpolation to return a list of points forming a line between two points on a grid. See eg/bench for a comparison of a perl Bresenham, a perl lerp, and the line function of this module.

Caveats include potential floating point portability problems and "aesthetic issues" depending on how lround behaves.

FUNCTION

Not exported by default.

line p1 p2

Given two points (array references of x, y values) returns an array reference of the points between the two points. This may simply be a copy of point p1 (when p1 and p2 are equal) or a longer list of points.

Magic is not supported.

SEE ALSO

Algorithm::Line::Bresenham

https://www.redblobgames.com/grids/line-drawing.html

AUTHOR

Jeremy Mates, <jmates@thrig.me>

COPYRIGHT AND LICENSE

Copyright 2023 Jeremy Mates

This program is distributed under the (Revised) BSD License: https://opensource.org/licenses/BSD-3-Clause