Math::PlanePath::File -- points from a file
use Math::PlanePath::File; my $path = Math::PlanePath::File->new (filename => 'foo.txt'); my ($x, $y) = $path->n_to_xy (123);
This path reads X,Y points from a file to present in PlanePath style. It's slightly preliminary yet but is handy to get numbers from elsewhere into a PlanePath program.
The intention is to be flexible about the file format and to auto-detect as far as possible. Currently the only format is plain text, with an X,Y pair, or N,X,Y triplet on each line
5,6 # X,Y 123 5 6 # N,X,Y
Numbers can be separated by a comma or just spaces and tabs. Lines not starting with a number are ignored as comments (or blanks). N values must be integers, but the X,Y values can be fractions like 1.5 too, including exponential floating point 1500.5e-1 etc.
See "FUNCTIONS" in Math::PlanePath for behaviour common to all path classes.
$path = Math::PlanePath::File->new (filename => "/my/file/name.txt")
Create and return a new path object.
($x,$y) = $path->n_to_xy ($n)
Return the X,Y coordinates of point number $n
on the path.
$n = $path->xy_to_n ($x,$y)
Return the point number for coordinates $x,$y
.
In the current code an $x,$y
within a unit circle or square of a point from the file gives that point. But perhaps in the future some attention could be paid to apparent spacing of points closer than that.
$bool = $path->x_negative()
$bool = $path->y_negative()
Return true if there are any negative X or negative Y coordinates in the file.
$n = $path->n_start()
Return the first N in the path. For files of just X,Y points the start is N=1, for N,X,Y data it's the first N.
$str = $path->figure()
Return a string name of the figure (shape) intended to be drawn at each $n
position. In the current code if all X,Y are integers then this is "square", otherwise it's "circle". But perhaps that will change.
http://user42.tuxfamily.org/math-planepath/index.html
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 Kevin Ryde
This file is part of Math-PlanePath.
Math-PlanePath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
Math-PlanePath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Math-PlanePath. If not, see <http://www.gnu.org/licenses/>.