1Math::PlanePath::File(3U)ser Contributed Perl DocumentatiMoanth::PlanePath::File(3)
2
3
4
6 Math::PlanePath::File -- points from a file
7
9 use Math::PlanePath::File;
10 my $path = Math::PlanePath::File->new (filename => 'foo.txt');
11 my ($x, $y) = $path->n_to_xy (123);
12
14 This path reads X,Y points from a file to present in PlanePath style.
15 It's slightly preliminary yet but is handy to get numbers from
16 elsewhere into a PlanePath program.
17
18 The intention is to be flexible about the file format and to auto-
19 detect as far as possible. Currently the only format is plain text,
20 with an X,Y pair, or N,X,Y triplet on each line
21
22 5,6 # X,Y
23 123 5 6 # N,X,Y
24
25 Numbers can be separated by a comma or just spaces and tabs. Lines not
26 starting with a number are ignored as comments (or blanks). N values
27 must be integers, but the X,Y values can be fractions like 1.5 too,
28 including exponential floating point 1500.5e-1 etc.
29
31 See "FUNCTIONS" in Math::PlanePath for behaviour common to all path
32 classes.
33
34 "$path = Math::PlanePath::File->new (filename => "/my/file/name.txt")"
35 Create and return a new path object.
36
37 "($x,$y) = $path->n_to_xy ($n)"
38 Return the X,Y coordinates of point number $n on the path.
39
40 "$n = $path->xy_to_n ($x,$y)"
41 Return the point number for coordinates "$x,$y".
42
43 In the current code an "$x,$y" within a unit circle or square of a
44 point from the file gives that point. But perhaps in the future
45 some attention could be paid to apparent spacing of points closer
46 than that.
47
48 "$bool = $path->x_negative()"
49 "$bool = $path->y_negative()"
50 Return true if there are any negative X or negative Y coordinates
51 in the file.
52
53 "$n = $path->n_start()"
54 Return the first N in the path. For files of just X,Y points the
55 start is N=1, for N,X,Y data it's the first N.
56
57 "$str = $path->figure()"
58 Return a string name of the figure (shape) intended to be drawn at
59 each $n position. In the current code if all X,Y are integers then
60 this is "square", otherwise it's "circle". But perhaps that will
61 change.
62
64 Math::PlanePath
65
67 <http://user42.tuxfamily.org/math-planepath/index.html>
68
70 Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020
71 Kevin Ryde
72
73 This file is part of Math-PlanePath.
74
75 Math-PlanePath is free software; you can redistribute it and/or modify
76 it under the terms of the GNU General Public License as published by
77 the Free Software Foundation; either version 3, or (at your option) any
78 later version.
79
80 Math-PlanePath is distributed in the hope that it will be useful, but
81 WITHOUT ANY WARRANTY; without even the implied warranty of
82 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
83 General Public License for more details.
84
85 You should have received a copy of the GNU General Public License along
86 with Math-PlanePath. If not, see <http://www.gnu.org/licenses/>.
87
88
89
90perl v5.38.0 2023-07-20 Math::PlanePath::File(3)