File Coverage

blib/lib/Math/Interpolator/Knot.pm
Criterion Covered Total %
statement 13 13 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 4 4 100.0
total 24 24 100.0


line stmt bran cond sub pod time code
1             =head1 NAME
2              
3             Math::Interpolator::Knot - x/y point for use in interpolation
4              
5             =head1 SYNOPSIS
6              
7             use Math::Interpolator::Knot;
8              
9             $pt = Math::Interpolator::Knot->new($x, $y);
10              
11             $x = $pt->x;
12             $y = $pt->y;
13              
14             $role = $pt->role;
15              
16             =head1 DESCRIPTION
17              
18             An object of this type represents a single known point on a
19             one-dimensional curve. It is intended for use with C,
20             which will interpolate a curve between known points. These points are
21             known as "knots".
22              
23             =cut
24              
25             package Math::Interpolator::Knot;
26              
27 9     9   38617 { use 5.006; }
  9         31  
  9         486  
28 9     9   45 use warnings;
  9         17  
  9         239  
29 9     9   51 use strict;
  9         16  
  9         1326  
30              
31             our $VERSION = "0.005";
32              
33             =head1 CONSTRUCTOR
34              
35             =over
36              
37             =item Math::Interpolator::Knot->new(X, Y)
38              
39             Creates and returns a new knot object with the specified x and y
40             coordinates.
41              
42             =cut
43              
44 83     83 1 864 sub new { bless({ x => $_[1], y => $_[2] }, $_[0]) }
45              
46             =back
47              
48             =head1 METHODS
49              
50             =over
51              
52             =item $pt->x
53              
54             Returns the x coordinate of the knot.
55              
56             =cut
57              
58 713     713 1 2351 sub x { $_[0]->{x} }
59              
60             =item $pt->y
61              
62             Returns the y coordinate of the knot.
63              
64             =cut
65              
66 406     406 1 1017 sub y { $_[0]->{y} }
67              
68             =item $pt->role
69              
70             Returns the string "KNOT". This is used to distinguish knots from other
71             types of entity that could appear in an interpolator's point list.
72              
73             =cut
74              
75 816     816 1 6195 sub role { "KNOT" }
76              
77             =back
78              
79             =head1 SUBCLASSING
80              
81             The interpolator uses only this public interface, so it is acceptable to
82             substitute any other class that implements this interface. This may be
83             done by subclassing this class, or by reimplementing all three methods
84             independently. This is useful, for example, if the exact coordinates
85             are expensive to calculate and it is desired to perform lazy evaluation
86             with memoisation.
87              
88             =head1 SEE ALSO
89              
90             L,
91             L
92              
93             =head1 AUTHOR
94              
95             Andrew Main (Zefram)
96              
97             =head1 COPYRIGHT
98              
99             Copyright (C) 2006, 2007, 2009, 2010, 2012
100             Andrew Main (Zefram)
101              
102             =head1 LICENSE
103              
104             This module is free software; you can redistribute it and/or modify it
105             under the same terms as Perl itself.
106              
107             =cut
108              
109             1;