1Math::PlanePath::Base::UGseenrerCiocn(t3r)ibuted Perl DoMcautmhe:n:tPaltainoenPath::Base::Generic(3)
2
3
4
6 Math::PlanePath::Base::Generic -- various path helpers
7
9 use Math::PlanePath::Base::Generic 'round_nearest';
10 $x = round_nearest($x);
11
13 This is a few generic helper functions for the PlanePath code. They're
14 designed to work on plain Perl integers and floats and in some cases
15 there's some special support for "Math::BigInt".
16
18 Nothing is exported by default but each function below can be as in the
19 usual Exporter style,
20
21 use Math::PlanePath::Base::Generic 'round_nearest';
22
23 (But not parameter_info_nstart0() and parameter_info_nstart1(), for the
24 reason described below.)
25
27 Generic
28 "$x = round_nearest ($x)"
29 Return $x rounded to the nearest integer. If $x is half way, such
30 as 2.5 then it's round upwards to 3.
31
32 $x = round_nearest($x);
33
34 "$href = Math::PlanePath::Base::Generic::parameter_info_nstart0()"
35 "$href = Math::PlanePath::Base::Generic::parameter_info_nstart1()"
36 Return an "n_start" parameter hashref suitable for use in a
37 parameter_info_array(), with default either 0 or 1. For example,
38
39 # alone
40 package Math::PlanePath::MySubclass;
41 use constant parameter_info_array =>
42 [ Math::PlanePath::Base::Generic::parameter_info_nstart1() ];
43
44 # or with other parameters too
45 package Math::PlanePath::MySubclass;
46 use constant parameter_info_array =>
47 [
48 { name => 'something',
49 type => 'integer',
50 default => '123',
51 },
52 Math::PlanePath::Base::Generic::parameter_info_nstart1(),
53 ];
54
55 This function is not exportable since it's meant for a one-off call
56 in an initializer and so no need to import it for repeated use.
57
59 Math::PlanePath, Math::PlanePath::Base::Digits,
60 Math::PlanePath::Base::NSEW
61
63 <http://user42.tuxfamily.org/math-planepath/index.html>
64
66 Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019,
67 2020, 2021 Kevin Ryde
68
69 This file is part of Math-PlanePath.
70
71 Math-PlanePath is free software; you can redistribute it and/or modify
72 it under the terms of the GNU General Public License as published by
73 the Free Software Foundation; either version 3, or (at your option) any
74 later version.
75
76 Math-PlanePath is distributed in the hope that it will be useful, but
77 WITHOUT ANY WARRANTY; without even the implied warranty of
78 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
79 General Public License for more details.
80
81 You should have received a copy of the GNU General Public License along
82 with Math-PlanePath. If not, see <http://www.gnu.org/licenses/>.
83
84
85
86perl v5.38.0 2023-07-20 Math::PlanePath::Base::Generic(3)