line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Math::Geometry::Construction::FixedPoint; |
2
|
1
|
|
|
1
|
|
1741
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
extends 'Math::Geometry::Construction::Point'; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use 5.008008; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Math::Geometry::Construction::Vector; |
8
|
|
|
|
|
|
|
use Math::Geometry::Construction::Types qw(Vector); |
9
|
|
|
|
|
|
|
use Math::Vector::Real; |
10
|
|
|
|
|
|
|
use Carp; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
C<Math::Geometry::Construction::FixedPoint> - independent user-defined point |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 VERSION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Version 0.024 |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = '0.024'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
########################################################################### |
26
|
|
|
|
|
|
|
# # |
27
|
|
|
|
|
|
|
# Accessors # |
28
|
|
|
|
|
|
|
# # |
29
|
|
|
|
|
|
|
########################################################################### |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
with 'Math::Geometry::Construction::Role::Buffering'; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has 'position_vector' => (isa => Vector, |
34
|
|
|
|
|
|
|
coerce => 1, |
35
|
|
|
|
|
|
|
is => 'rw', |
36
|
|
|
|
|
|
|
required => 1, |
37
|
|
|
|
|
|
|
init_arg => 'position', |
38
|
|
|
|
|
|
|
trigger => \&clear_global_buffer); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub BUILDARGS { |
41
|
|
|
|
|
|
|
my ($class, %args) = @_; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
if(defined($args{x}) and defined($args{y})) { |
44
|
|
|
|
|
|
|
$args{position} = V($args{x}, $args{y}); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
return \%args; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
########################################################################### |
51
|
|
|
|
|
|
|
# # |
52
|
|
|
|
|
|
|
# Retrieve Data # |
53
|
|
|
|
|
|
|
# # |
54
|
|
|
|
|
|
|
########################################################################### |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub position { |
57
|
|
|
|
|
|
|
my ($self, @args) = @_; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
return $self->position_vector(@args) if(@args); |
60
|
|
|
|
|
|
|
return $self->position_vector->value; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
########################################################################### |
64
|
|
|
|
|
|
|
# # |
65
|
|
|
|
|
|
|
# Change Data # |
66
|
|
|
|
|
|
|
# # |
67
|
|
|
|
|
|
|
########################################################################### |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__END__ |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=pod |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 SYNOPSIS |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
my $p1 = $construction->add_point(position => [100, 150]); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my $p2 = $construction->add_point('x' => 50, 'y' => 90, |
81
|
|
|
|
|
|
|
hidden => 1); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
my $p3 = $construction->add_point('x' => 70, 'y' => 130, |
84
|
|
|
|
|
|
|
style => {stroke => 'red'}, |
85
|
|
|
|
|
|
|
label => 'A', |
86
|
|
|
|
|
|
|
label_offset_x => 5, |
87
|
|
|
|
|
|
|
label_offset_y => -5); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 DESCRIPTION |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
An instance of this class represents a user defined free point, as |
93
|
|
|
|
|
|
|
opposed to a derived point, e.g. an intersection point. An instance |
94
|
|
|
|
|
|
|
of this class got its position directly from the user. It is created |
95
|
|
|
|
|
|
|
by using the L<add_point |
96
|
|
|
|
|
|
|
method|Math::Geometry::Construction/add_point> of |
97
|
|
|
|
|
|
|
C<Math::Geometry::Construction>. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 INTERFACE |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 Public Attributes |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head3 position |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
The accessor returns a L<Math::Vector::Real|Math::Vector::Real> |
106
|
|
|
|
|
|
|
object with the position of the point. To the constructor or |
107
|
|
|
|
|
|
|
mutator, you can give anything that |
108
|
|
|
|
|
|
|
L<Math::Geometry::Construction::Vector|Math::Geometry::Construction::Vector> |
109
|
|
|
|
|
|
|
accepts. The constructor additionally supports explicit C<x> and |
110
|
|
|
|
|
|
|
C<y> arguments. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Examples: |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# arrayref |
115
|
|
|
|
|
|
|
$construction->add_point(position => [1, 4]); |
116
|
|
|
|
|
|
|
$construction->position([5, -3]); |
117
|
|
|
|
|
|
|
$construction->position([4, -1, 7]); # 7 is ignored |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# Math::Vector::Real object |
120
|
|
|
|
|
|
|
$construction->add_point(position => V(1, 4)); |
121
|
|
|
|
|
|
|
$construction->position(V(5, -3)); |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# x and y |
124
|
|
|
|
|
|
|
$construction->add_point('x' => 1, 'y' => 4); |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
See also |
127
|
|
|
|
|
|
|
L<Math::Geometry::Construction::Vector|Math::Geometry::Construction::Vector>. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Note that you must not alter the elements of the |
130
|
|
|
|
|
|
|
C<Math::Vector::Real> object directly although the class interface |
131
|
|
|
|
|
|
|
allows it. This will circumvent the tracking of changes that |
132
|
|
|
|
|
|
|
C<Math::Geometry::Construction> performs in order to improve |
133
|
|
|
|
|
|
|
performance. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
$point = $construction->add_point([5, 7]); |
136
|
|
|
|
|
|
|
$pos = $point->position; |
137
|
|
|
|
|
|
|
$pos->[0] = 6; # wrong! |
138
|
|
|
|
|
|
|
$point->position([6, 7]); # right |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head3 size |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
A point is currently always drawn as a circle. This might become |
143
|
|
|
|
|
|
|
more flexible in the future. C<size> determines the size of the |
144
|
|
|
|
|
|
|
point in the output. For a circle it is its diameter. This parameter |
145
|
|
|
|
|
|
|
is currently C<undef> by default, because the output falls back to |
146
|
|
|
|
|
|
|
L<radius|/radius> (see below). When C<radius> is removed, C<size> |
147
|
|
|
|
|
|
|
will default to C<6>. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head3 radius |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Half of L<size|/size>. This attribute is deprecated and might be |
152
|
|
|
|
|
|
|
removed in a future version. Use L<size|/size> instead. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head2 General Output Attributes |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
See |
157
|
|
|
|
|
|
|
L<Math::Geometry::Construction::Output|Math::Geometry::Construction::Output>. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head2 Methods |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head3 draw |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Called by the C<Construction> object during output generation. |
164
|
|
|
|
|
|
|
Currently draws a circle of diameter L<size|/size>, but this might |
165
|
|
|
|
|
|
|
become more flexible in the future. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head3 id_template |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Class method returning C<$ID_TEMPLATE>, which defaults to C<'P%09d'>. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 AUTHOR |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Lutz Gehlen, C<< <perl at lutzgehlen.de> >> |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Copyright 2011, 2013 Lutz Gehlen. |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
182
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
183
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=cut |