Diagram2D/Plot.pm

filter: Statementstmt 1.4% 18 / 1260 Branchbran 0.0% 0 / 344 Conditioncond 0.0% 0 / 54 MC/DCmcdc 0.0% 0 / 28 Subroutinesub 10.0% 5 / 50 Podpod 0.0% 0 / 45 totaltotal 1.2% 23 / 1781 CC 193 SCAR 49.9
CC
193
Cov
1%
set_dots
506.0
finish
342.0
plot_to
342.0
CRAP 146.2
« Diagram2D.pm ↑ Summary Diagram2D/Axis.pm »
1  
2 package LaTeX::PGF::Diagram2D::Plot;
3  
4 1 ▶use 5.000000;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 our @ISA = qw();
11  
12 1 our $VERSION = '1.00';
13  
14 1 require LaTeX::PGF::Diagram2D::Xspline;
15  
16 # Plot types, Output (t):
17 # 0 Dots
18 # 1 Curve
19 # 2 Lines
20  
21 # Plot data types, input (d):
22 # 0 Function, optionally with derivative given
23 # d1=function, d2=derivative
24 # 1 Points (optionally with a derivative)
25 # d1=reference to array of points
26 # 2 Parametric function
27 # d1=xfunction d2=yfunction, d3=xderivative (opt), d4=yderivative (opt)
28 # 3 X-spline points (open spline)
29  
30  
31  
32  
33 # Dot style:
34 # 0 = circle
35 # 1 = square
36 # 2 = diamond
37 # 3 = triangle
38 # 4 = crosshair
39 # 5 = pentagon
40  
41  
42 1 ▶use PDL;
Subroutine BEGIN: called CC=1 SCAR=0.0
43  
44  
45  
46 sub new
47 0 ▶{
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
48 0 my $self = undef;
49 0 ▶ if($#_ < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ < 0) { } 0 0 0
50 0 croak "Usage: LaTeX::PGF::Diagram2D::Plot->new()";
51 } else {
52 0 my $class = shift;
53 0 $self = {
54 't' => 1, # Plot type: -1=unknown, 0=points, 1=curve, 2=lines
55 'd' => -1, # Data type: -1=unknown, 0=function, 1=points, 2=param
56 'r' => undef, # Range (for undef use entire x-axis or plot points)
57 'd1' => undef, # Data 1 (Function or array of points)
58 'd2' => undef, # Data 2 (Derivative function)
59 'd3' => undef, # Data 3
60 'd4' => undef, # Data 4
61 'f' => undef, # Flag: Finished.
62 'ax' => undef, # x axis
63 'ay' => undef, # y axis
64 'color' => undef, # Plot color
65 'pp' => undef, # Paper points (userspace coordinates)
66 'i' => 20, # Number of curve intervals
67 'ds' => 0, # Dot style
68 'dsz' => 5.0, # Dot size (diameter, multiple of line size)
69 'debug' => 0, # Flag: Debug
70 'xspline' => 8, # Bezier segments per X-spline segment
71 };
72 0 bless($self, $class);
73 }
74 0 return $self;
75 }
76  
77  
78 sub set_xy_fct
79 0 ▶{
Subroutine set_xy_fct: not called CC=3 SCAR=24.8
Pod undocumented
80 0 my $self = undef;
81 0 ▶ if($#_ < 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ < 1) { } 0 0 0
82 0 croak "Usage: \$plot->set_xy_fct(function,[derivative-function])";
83 } else {
84 0 $self = shift;
85 0 $self->{'d1'} = shift;
86 0 ▶ if($#_ >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ >= 0) 0 0 0
87 0 $self->{'d2'} = shift;
88 }
89 0 $self->{'d'} = 0;
90 }
91 0 return $self;
92 }
93  
94  
95  
96 sub set_parametric_fct
97 0 ▶{
Subroutine set_parametric_fct: not called CC=3 SCAR=24.8
Pod undocumented
98 0 my $self = undef;
99 0 ▶ if($#_ < 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ < 4) { } 0 0 0
100 0 croak "Usage: \$plot->set_parametric_fct(min, max, xfct, yfct[, xderiv, yderiv]);";
101 } else {
102 0 $self = shift;
103 0 my $min = shift;
104 0 my $max = shift;
105 0 $self->{'r'} = [ $min, $max ];
106 0 $self->{'d1'} = shift;
107 0 $self->{'d2'} = shift;
108 0 $self->{'d'} = 2;
109 0 ▶ if($#_ >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ >= 1) 0 0 0
110 0 $self->{'d3'} = shift;
111 0 $self->{'d4'} = shift;
112 }
113 }
114 0 return $self;
115 }
116  
117  
118  
119 sub set_xy_points
120 0 ▶{
Subroutine set_xy_points: not called CC=2 SCAR=17.9
Pod undocumented
121 0 my $self = undef;
122 0 ▶ if($#_ < 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ < 1) { } 0 0 0
123 0 croak "Usage: \$plot->set_xy_points(pointsarrayref)";
124 } else {
125 0 $self = shift;
126 0 $self->{'d1'} = shift;
127 0 $self->{'d'} = 1;
128 }
129 0 return $self;
130 }
131  
132  
133  
134 sub set_xy_points_text
135 0 ▶{
Subroutine set_xy_points_text: not called CC=6 SCAR=37.4
Pod undocumented
136 0 my $self = undef;
137 0 ▶ if($#_ < 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ < 1) { } 0 0 0
138 0 croak "Usage: \$plot->set_xy_points_text(text)";
139 } else {
140 0 $self = shift;
141 0 my $text = shift;
142 0 my @array;
143 0 my $na = 0;
144 0 my $x;
145 my $y;
146 0 my $d;
147 0 foreach my $line (split(/\n/, $text)) {
148 0 $x = 0.0; $y = 0.0; $d = 0.0;
149 0 ▶ if($line =~ /\S/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /\S/o) 0 0 0
150 0 ▶ if($line =~ /^\s*(\S+)\s+(\S+)\s+(\S+)/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^\s*(\S+)\s+(\S+)\s+(\S+)/o) { } 0 0 0
151 0 $x = $1; $y = $2; $d = $3;
152 0 $array[$na++] = [ $x, $y, $d ];
153 } else {
154 0 ▶ if($line =~ /^\s*(\S+)\s+(\S+)/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^\s*(\S+)\s+(\S+)/o) { } 0 0 0
155 0 $x = $1; $y = $2;
156 0 $array[$na++] = [ $x, $y ];
157 } else {
158 0 croak "ERROR: Illegal line \"$line\" in text!";
159 }
160 }
161 }
162 }
163 0 $self->{'d1'} = \@array; $self->{'d'} = 1;
164 }
165 0 return $self;
166 }
167  
168  
169  
170 sub set_xy_points_file
171 0 ▶{
Subroutine set_xy_points_file: not called CC=7 SCAR=40.3
Pod undocumented
172 0 my $self = undef;
173 0 ▶ if($#_ < 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ < 1) { } 0 0 0
174 0 croak "Usage: \$plot->set_xy_points_file(filename)";
175 } else {
176 0 $self = shift; my $fn = shift; my $line;
177 0 my @array; my $na = 0;
178 0 my $x; my $y; my $d;
179 0 ▶ if(open(my $fh, '<', "$fn")) {
Branch: 1 branch
BranchTrueFalseTotal
if (open my $fh, "<", "$fn") 0 0 0
180 0 ▶ while(<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
181 0 $line = $_; chomp $line;
182 0 ▶ if($line =~ /\S/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /\S/o) 0 0 0
183 0 ▶ if($line =~ /^\s*(\S+)\s+(\S+)\s+(\S+)/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^\s*(\S+)\s+(\S+)\s+(\S+)/o) { } 0 0 0
184 0 $x = $1; $y = $2; $d = $3;
185 0 $array[$na++] = [ $x, $y, $d ];
186 } else {
187 0 ▶ if($line =~ /^\s*(\S+)\s+(\S+)/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^\s*(\S+)\s+(\S+)/o) 0 0 0
188 0 $x = $1; $y = $2;
189 0 $array[$na++] = [ $x, $y ];
190 }
191 }
192 }
193 }
194 0 close($fh); $fh = undef;
195 0 $self->{'d1'} = \@array; $self->{'d'} = 1;
196 }
197 }
198 0 return $self;
199 }
200  
201  
202  
203 sub set_xsplines_points
204 0 ▶{
Subroutine set_xsplines_points: not called CC=10 SCAR=47.0
Pod undocumented
205 0 my $self = undef;
206 0 my @pp; my $npp = 0; my $pr; my $x; my $y; my $s;
207 0 ▶ if($#_ < 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ < 1) { } 0 0 0
208 0 croak "Usage: \$plot->set_xspline_points(arrayref [, s_default ])";
209 } else {
210 0 $self = shift;
211 0 my $ar = shift;
212 0 my $sdef = -1.0;
213 0 ▶ if($#_ >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ >= 0) 0 0 0
214 0 $sdef = shift;
215 0 ▶ if($sdef < -1.0) { $sdef = -1.0; }
Branch: 1 branch
BranchTrueFalseTotal
if ($sdef < -1) 0 0 0
216 0 ▶ if($sdef > 1.0) { $sdef = 1.0; }
Branch: 1 branch
BranchTrueFalseTotal
if ($sdef > 1) 0 0 0
217 }
218 0 ▶ for(my $i = 0; $i <= $#$ar; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $ar->$#*) 0 0 0
219 0 $pr = $ar->[$i];
220 0 ▶ if($#$pr > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pr->$#* > 0) 0 0 0
221 0 $x = $pr->[0]; $y = $pr->[1]; $s = $sdef;
222 0 ▶ if($#$pr > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pr->$#* > 1) 0 0 0
223 0 $s = $pr->[2];
224 0 ▶ if($s < -1.0) { $s = -1.0; }
Branch: 1 branch
BranchTrueFalseTotal
if ($s < -1) 0 0 0
225 0 ▶ if($s > 1.0) { $s = 1.0; }
Branch: 1 branch
BranchTrueFalseTotal
if ($s > 1) 0 0 0
226 }
227 0 $pp[$npp++] = [ $x, $y, $s ];
228 }
229 }
230 0 $self->{'d1'} = \@pp; $self->{'d'} = 3;
231 }
232 0 return $self;
233 }
234  
235  
236  
237 sub set_xsplines_points_text
238 0 ▶{
Subroutine set_xsplines_points_text: not called CC=11 SCAR=48.8
Pod undocumented
239 0 my $self = undef;
240 0 ▶ if($#_ < 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ < 1) { } 0 0 0
241 0 croak "Usage: \$plot->set_xsplines_points_text(text [, s_default ])";
242 } else {
243 0 $self = shift; my $t = shift; my $sdef = -1.0;
244 0 my $x; my $y; my $s;
245 0 my @pp; my $npp = 0;
246 0 ▶ if($#_ >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ >= 0) 0 0 0
247 0 $sdef = shift;
248 0 ▶ if($sdef < -1.0) { $sdef = -1.0; }
Branch: 1 branch
BranchTrueFalseTotal
if ($sdef < -1) 0 0 0
249 0 ▶ if($sdef > 1.0) { $sdef = 1.0; }
Branch: 1 branch
BranchTrueFalseTotal
if ($sdef > 1) 0 0 0
250 }
251 0 foreach my $line (split(/\n/, $t)) {
252 0 $x = 0.0; $y = 0.0; $s = $sdef;
253 0 ▶ if($line =~ /\S/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /\S/o) 0 0 0
254 0 ▶ if($line =~ /^\s*(\S+)\s+(\S+)\s+(\S+)/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^\s*(\S+)\s+(\S+)\s+(\S+)/o) { } 0 0 0
255 0 $x = $1; $y = $2; $s = $3;
256 0 ▶ if($s < -1.0) { $s = -1.0; }
Branch: 1 branch
BranchTrueFalseTotal
if ($s < -1) 0 0 0
257 0 ▶ if($s > 1.0) { $s = 1.0; }
Branch: 1 branch
BranchTrueFalseTotal
if ($s > 1) 0 0 0
258 0 $pp[$npp++] = [ $x, $y, $s ];
259 } else {
260 0 ▶ if($line =~ /^\s*(\S+)\s+(\S+)/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^\s*(\S+)\s+(\S+)/o) 0 0 0
261 0 $x = $1; $y = $2;
262 0 $pp[$npp++] = [ $x, $y, $sdef ];
263 }
264 }
265 }
266 }
267 0 $self->{'d1'} = \@pp; $self->{'d'} = 3;
268 }
269 0 return $self;
270 }
271  
272  
273  
274 sub set_xspline_points_file
275 0 ▶{
Subroutine set_xspline_points_file: not called CC=12 SCAR=50.5
Pod undocumented
276 0 my $self = undef;
277 0 ▶ if($#_ < 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ < 1) { } 0 0 0
278 0 croak "Usage: \$plot->set_xspline_points_file(filename [, s_default ])";
279 } else {
280 0 $self = shift; my $fn = shift; my $sdef = -1; my $fh = undef;
281 0 my $line; my $x; my $y; my $s;
282 0 my @pp; my $npp = 0;
283 0 ▶ if($#_ >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ >= 0) 0 0 0
284 0 $sdef = shift;
285 0 ▶ if($sdef < -1.0) { $sdef = -1.0; }
Branch: 1 branch
BranchTrueFalseTotal
if ($sdef < -1) 0 0 0
286 0 ▶ if($sdef > 1.0) { $sdef = 1.0; }
Branch: 1 branch
BranchTrueFalseTotal
if ($sdef > 1) 0 0 0
287 }
288 0 ▶ if(open($fh, '<', $fn)) {
Branch: 1 branch
BranchTrueFalseTotal
if (open $fh, "<", $fn) 0 0 0
289 0 ▶ while(<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
290 0 $line = $_; chomp $line;
291 0 $x = 0.0; $y = 0.0; $s = $sdef;
292 0 ▶ if($line =~ /\S/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /\S/o) 0 0 0
293 0 ▶ if($line =~/^\s*(\S+)\s+(\S+)\s+(\S+)/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^\s*(\S+)\s+(\S+)\s+(\S+)/o) { } 0 0 0
294 0 $x = $1; $y = $2; $s = $3;
295 0 ▶ if($s < -1.0) { $s = -1.0; }
Branch: 1 branch
BranchTrueFalseTotal
if ($s < -1) 0 0 0
296 0 ▶ if($s > 1.0) { $s = 1.0; }
Branch: 1 branch
BranchTrueFalseTotal
if ($s > 1) 0 0 0
297 0 $pp[$npp++] = [ $x, $y, $s ];
298 } else {
299 0 ▶ if($line =~/^\s*(\S+)\s+(\S+)/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^\s*(\S+)\s+(\S+)/o) 0 0 0
300 0 $x = $1; $y = $2;
301 0 $pp[$npp++] = [ $x, $y, $sdef ];
302 }
303 }
304 }
305 }
306 0 close($fh);
307 0 $self->{'d1'} = \@pp; $self->{'d'} = 3;
308 }
309 }
310 0 return $self;
311 }
312  
313  
314  
315 sub finish_points_points
316 0 ▶{
Subroutine finish_points_points: not called CC=1 SCAR=6.9
Pod undocumented
317 0 my $self = shift;
318 0 $self->{'pp'} = $self->{'d1'};
319 0 return $self;
320 }
321  
322  
323  
324 sub finish_points_lines
325 0 ▶{
Subroutine finish_points_lines: not called CC=1 SCAR=6.9
Pod undocumented
326 0 my $self = shift;
327 0 $self->{'pp'} = $self->{'d1'};
328 0 return $self;
329 }
330  
331  
332  
333 sub finish_points_curve
334 0 ▶{
Subroutine finish_points_curve: not called CC=1 SCAR=6.9
Pod undocumented
335 0 my $self = shift;
336 0 $self->{'pp'} = $self->{'d1'};
337 0 return $self;
338 }
339  
340  
341  
342 sub finish_function_points
343 0 ▶{
Subroutine finish_function_points: not called CC=6 SCAR=37.4
Pod undocumented
344 0 my $self = shift;
345 0 my @dp; # data points
346 0 my $ndp = 0; # Number of data points
347 0 my $xs = $self->{'ax'}->{'min'};
348 0 my $xe = $self->{'ax'}->{'max'};
349 0 my $rp = $self->{'range'};
350 0 my $x = 0.0;
351 0 my $y = 0.0;
352 0 ▶ if(defined($rp)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $rp) 0 0 0
353 0 $xs = $rp->[0]; $xe = $rp->[1];
354 }
355 0 my $diff = $xe - $xs;
356 0 my $i = $self->{'i'};
357 0 ▶ if(defined($self->{'d1'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"d1"}) 0 0 0
358 0 my $fp = $self->{'d1'};
359 0 ▶ if($self->{'ax'}->{'t'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'ax'}{'t'}) { } 0 0 0
360 0 $diff = exp(log($xe/$xs)/(1.0 * $i));
361 0 $x = $xs;
362 0 $y = &$fp($x);
363 0 $dp[0] = [ $x, $y ];
364 0 ▶ for(my $j = 1; $j < $i; $j++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j < $i) 0 0 0
365 0 $x = $x * $diff;
366 0 $y = &$fp($x);
367 0 $dp[$j] = [ $x, $y ];
368 }
369 0 $x = $xe;
370 0 $y = &$fp($x);
371 0 $dp[$i] = [ $x, $y ];
372 } else {
373 0 $x = $xs;
374 0 $y = &$fp($x);
375 0 $dp[0] = [ $x, $y ];
376 0 ▶ for(my $j = 1; $j < $i; $j++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j < $i) 0 0 0
377 0 $x = $xs + ((1.0 * $j) * $diff)/(1.0 * $i);
378 0 $y = &$fp($x);
379 0 $dp[$j] = [ $x, $y ];
380 }
381 0 $x = $xe;
382 0 $y = &$fp($x);
383 0 $dp[$i] = [ $x, $y ];
384 }
385 0 $self->{'pp'} = \@dp;
386 }
387 0 return $self;
388 }
389  
390  
391  
392 sub finish_function_curve
393 0 ▶{
Subroutine finish_function_curve: not called CC=7 SCAR=40.3
Pod undocumented
394 0 my $self = shift;
395 0 ▶ if(defined($self->{'d2'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'d2'}) { } 0 0 0
396 0 my @dp; # data points
397 0 my $ndp = 0; # Number of data points
398 0 my $xs = $self->{'ax'}->{'min'};
399 0 my $xe = $self->{'ax'}->{'max'};
400 0 my $rp = $self->{'range'};
401 0 my $x = 0.0;
402 0 my $y = 0.0;
403 0 my $z = 0.0;
404 0 ▶ if(defined($rp)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $rp) 0 0 0
405 0 $xs = $rp->[0]; $xe = $rp->[1];
406 }
407 0 my $diff = $xe - $xs;
408 0 my $i = $self->{'i'};
409 0 ▶ if(defined($self->{'d1'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"d1"}) 0 0 0
410 0 my $fp = $self->{'d1'};
411 0 my $dfp = $self->{'d2'};
412 0 ▶ if($self->{'ax'}->{'t'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'ax'}{'t'}) { } 0 0 0
413 0 $diff = exp(log($xe/$xs)/(1.0 * $i));
414 0 $x = $xs;
415 0 $y = &$fp($x);
416 0 $z = &$dfp($x);
417 0 $dp[0] = [ $x, $y, $z ];
418 0 ▶ for(my $j = 1; $j < $i; $j++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j < $i) 0 0 0
419 0 $x = $x * $diff;
420 0 $y = &$fp($x);
421 0 $z = &$dfp($x);
422 0 $dp[$j] = [ $x, $y, $z ];
423 }
424 0 $x = $xe;
425 0 $y = &$fp($x);
426 0 $z = &$dfp($x);
427 0 $dp[$i] = [ $x, $y, $z ];
428 } else {
429 0 $x = $xs;
430 0 $y = &$fp($x);
431 0 $z = &$dfp($x);
432 0 $dp[0] = [ $x, $y, $z ];
433 0 ▶ for(my $j = 1; $j < $i; $j++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j < $i) 0 0 0
434 0 $x = $xs + ((1.0 * $j) * $diff)/(1.0 * $i);
435 0 $y = &$fp($x);
436 0 $z = &$dfp($x);
437 0 $dp[$j] = [ $x, $y, $z ];
438 }
439 0 $x = $xe;
440 0 $y = &$fp($x);
441 0 $z = &$dfp($x);
442 0 $dp[$i] = [ $x, $y, $z ];
443 }
444 0 $self->{'pp'} = \@dp;
445 }
446 } else {
447 0 $self->finish_function_points();
448 }
449 0 return $self;
450 }
451  
452  
453  
454 sub finish_param_points
455 0 ▶{
Subroutine finish_param_points: not called CC=5 SCAR=34.0
Pod undocumented
456 0 my $self = shift;
457 0 ▶ if(defined($self->{'r'}) && defined($self->{'d1'}) && defined($self->{'d2'}))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"r"} and defined $self->{"d1"} and defined $self->{"d2"}) 0 0 0
Condition0%0/6
defined $self->{"r"} and defined $self->{"d1"} and defined $self->{"d2"}
!ll&&!rl&&r
000
defined $self->{"r"} and defined $self->{"d1"}
!ll&&!rl&&r
000
MC/DC0%0/3
defined $self->{"r"} and defined $self->{"d1"} and defined $self->{"d2"}
defined $self->{"r"} defined $self->{"d1"} defined $self->{"d2"}
Truth table0%0/4
A and B and C
A= defined $self->{"r"}B= defined $self->{"d1"}C= defined $self->{"d2"}
ABCresult
0XX0
10X0
1100
1111
458 {
459 0 my @pp; my $npp = 0;
460 0 my $range = $self->{'r'}; my $fx = $self->{'d1'}; my $fy = $self->{'d2'};
461 0 my $mint = $range->[0]; my $maxt = $range->[1]; my $i = $self->{'i'};
462 0 my $x; my $y;
463 0 my $t;
464 0 $t = $mint;
465 0 $x = &$fx($t); $y = &$fy($t);
466 0 $pp[$npp++] = [ $t, $x, $y, undef, undef ];
467 0 ▶ for(my $j = 1; $j < $i; $j++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j < $i) 0 0 0
468 0 $t = $mint + ((1.0 * $j) * ($maxt - $mint)) / (1.0 * $i);
469 0 $x = &$fx($t); $y = &$fy($t);
470 0 $pp[$npp++] = [ $t, $x, $y, undef, undef ];
471 }
472 0 $t = $maxt;
473 0 $x = &$fx($t); $y = &$fy($t);
474 0 $pp[$npp++] = [ $t, $x, $y, undef, undef ];
475 0 $self->{'pp'} = \@pp;
476 }
477 0 return $self;
478 }
479  
480  
481  
482 sub finish_param_curve
483 0 ▶{
Subroutine finish_param_curve: not called CC=10 SCAR=47.0
Pod undocumented
484 0 my $self = shift;
485 0 ▶ if(defined($self->{'r'}) && defined($self->{'d1'}) && defined($self->{'d2'}))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"r"} and defined $self->{"d1"} and defined $self->{"d2"}) 0 0 0
Condition0%0/6
defined $self->{"r"} and defined $self->{"d1"} and defined $self->{"d2"}
!ll&&!rl&&r
000
defined $self->{"r"} and defined $self->{"d1"}
!ll&&!rl&&r
000
MC/DC0%0/3
defined $self->{"r"} and defined $self->{"d1"} and defined $self->{"d2"}
defined $self->{"r"} defined $self->{"d1"} defined $self->{"d2"}
Truth table0%0/4
A and B and C
A= defined $self->{"r"}B= defined $self->{"d1"}C= defined $self->{"d2"}
ABCresult
0XX0
10X0
1100
1111
486 {
487 0 my @pp; my $npp = 0;
488 0 my $range = $self->{'r'};
489 0 my $fx = $self->{'d1'}; my $fy = $self->{'d2'};
490 0 my $fxx = undef; my $fyy = undef;
491 0 ▶ if(defined($self->{'d3'}) && defined($self->{'d4'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"d3"} and defined $self->{"d4"}) 0 0 0
Condition0%0/3
defined $self->{"d3"} and defined $self->{"d4"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"d3"} and defined $self->{"d4"}
defined $self->{"d3"} defined $self->{"d4"}
Truth table0%0/3
A and B
A= defined $self->{"d3"}B= defined $self->{"d4"}
ABresult
0X0
100
111
492 0 $fxx = $self->{'d3'}; $fyy = $self->{'d4'};
493 }
494 0 my $mint = $range->[0]; my $maxt = $range->[1]; my $i = $self->{'i'};
495 0 my $x; my $y; my $xx; my $yy;
496 0 my $t;
497 0 $t = $mint;
498 0 $x = &$fx($t); $y = &$fy($t); $xx = undef; $yy = undef;
499 0 ▶ if(defined($fxx)) { $xx = &$fxx($t); $yy = &$fyy($t); }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fxx) 0 0 0
500 0 $pp[$npp++] = [ $t, $x, $y, $xx, $yy ];
501 0 ▶ for(my $j = 1; $j < $i; $j++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j < $i) 0 0 0
502 0 $t = $mint + ((1.0 * $j) * ($maxt - $mint)) / (1.0 * $i);
503 0 $x = &$fx($t); $y = &$fy($t); $xx = undef; $yy = undef;
504 0 ▶ if(defined($fxx)) { $xx = &$fxx($t); $yy = &$fyy($t); }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fxx) 0 0 0
505 0 $pp[$npp++] = [ $t, $x, $y, $xx, $yy ];
506 }
507 0 $t = $maxt;
508 0 $x = &$fx($t); $y = &$fy($t); $xx = undef; $yy = undef;
509 0 ▶ if(defined($fxx)) { $xx = &$fxx($t); $yy = &$fyy($t); }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fxx) 0 0 0
510 0 $pp[$npp++] = [ $t, $x, $y, $xx, $yy ];
511 0 $self->{'pp'} = \@pp;
512 }
513 0 return $self;
514 }
515  
516  
517  
518 sub finish
519 0 ▶{
Subroutine finish: not called CC=18 SCAR=58.3
Pod undocumented
520 0 my $self = undef;
521 0 ▶ if($#_ < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ < 0) { } 0 0 0
522 0 croak "Usage: \$plot->finish()";
523 } else {
524 0 $self = shift;
525 0 ▶ if(!defined($self->{'f'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"f"}) 0 0 0
526 0 my $pt = $self->{'t'};
527 0 my $dt = $self->{'d'};
528 0 ▶ if($pt == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pt == 0) { } 0 0 0
529 0 ▶ if($dt == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 0) { } 0 0 0
530 0 $self->finish_function_points();
531 } else {
532 0 ▶ if($dt == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 1) { } 0 0 0
533 0 $self->finish_points_points();
534 } else {
535 0 ▶ if($dt == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 2) { } 0 0 0
536 0 $self->finish_param_points();
537 } else {
538 0 ▶ if($dt == 3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 3) 0 0 0
539 0 $self->finish_points_points();
540 }
541 }
542 }
543 }
544 } else {
545 0 ▶ if($pt == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pt == 1) { } 0 0 0
546 0 ▶ if($dt == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 0) { } 0 0 0
547 0 $self->finish_function_curve();
548 } else {
549 0 ▶ if($dt == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 1) { } 0 0 0
550 0 $self->finish_points_curve();
551 } else {
552 0 ▶ if($dt == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 2) { } 0 0 0
553 0 $self->finish_param_curve();
554 } else {
555 0 ▶ if($dt == 3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 3) 0 0 0
556 0 $self->finish_points_points();
557 }
558 }
559 }
560 }
561 } else {
562 0 ▶ if($pt == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pt == 2) 0 0 0
563 0 ▶ if($dt == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 0) { } 0 0 0
564 0 $self->finish_function_points();
565 } else {
566 0 ▶ if($dt == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 1) { } 0 0 0
567 0 $self->finish_points_lines();
568 } else {
569 0 ▶ if($dt == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 2) { } 0 0 0
570 0 $self->finish_param_points();
571 } else {
572 0 ▶ if($dt == 3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 3) 0 0 0
573 0 $self->finish_points_points();
574 }
575 }
576 }
577 }
578 }
579 }
580 }
581 0 $self->{'f'} = 1;
582 }
583 }
584 0 return $self;
585 }
586  
587  
588  
589 sub dot_circle
590 0 ▶{
Subroutine dot_circle: not called CC=1 SCAR=6.9
Pod undocumented
591 0 my $self = shift;
592 0 my $dg = shift;
593 0 my $fh = shift;
594 0 my $x = shift;
595 0 my $y = shift;
596 0 my $diameter = shift;
597 0 print $fh "\\pgfpathcircle{";
598 0 $dg->write_point($x, $y);
599 0 print $fh "}{" . (0.5 * $diameter) . "bp}\\pgfusepath{fill}\n";
600 0 return $self;
601 }
602  
603  
604  
605 sub dot_square
606 0 ▶{
Subroutine dot_square: not called CC=1 SCAR=6.9
Pod undocumented
607 0 my $self = shift;
608 0 my $dg = shift;
609 0 my $fh = shift;
610 0 my $x = shift;
611 0 my $y = shift;
612 0 my $diameter = shift;
613 0 print $fh "\\pgfpathmoveto{";
614 0 $dg->write_point(($x - 0.5 * $diameter), ($y - 0.5 * $diameter));
615 0 print $fh "}\n";
616 0 print $fh "\\pgfpathlineto{";
617 0 $dg->write_point(($x + 0.5 * $diameter), ($y - 0.5 * $diameter));
618 0 print $fh "}\n";
619 0 print $fh "\\pgfpathlineto{";
620 0 $dg->write_point(($x + 0.5 * $diameter), ($y + 0.5 * $diameter));
621 0 print $fh "}\n";
622 0 print $fh "\\pgfpathlineto{";
623 0 $dg->write_point(($x - 0.5 * $diameter), ($y + 0.5 * $diameter));
624 0 print $fh "}\n\\pgfpathclose\\pgfusepath{fill}\n";
625 0 return $self;
626 }
627  
628  
629  
630 sub dot_diamond
631 0 ▶{
Subroutine dot_diamond: not called CC=1 SCAR=6.9
Pod undocumented
632 0 my $self = shift;
633 0 my $dg = shift;
634 0 my $fh = shift;
635 0 my $x = shift;
636 0 my $y = shift;
637 0 my $diameter = shift;
638 0 my $d = $diameter / sqrt(2.0);
639 0 print $fh "\\pgfpathmoveto{";
640 0 $dg->write_point($x, ($y + $d));
641 0 print $fh "}\n";
642 0 print $fh "\\pgfpathlineto{";
643 0 $dg->write_point(($x - $d), $y);
644 0 print $fh "}\n";
645 0 print $fh "\\pgfpathlineto{";
646 0 $dg->write_point($x, ($y - $d));
647 0 print $fh "}\n";
648 0 print $fh "\\pgfpathlineto{";
649 0 $dg->write_point(($x + $d), $y);
650 0 print $fh "}\n\\pgfpathclose\\pgfusepath{fill}\n";
651 0 return $self;
652 }
653  
654  
655  
656 sub dot_triangle
657 0 ▶{
Subroutine dot_triangle: not called CC=1 SCAR=6.9
Pod undocumented
658 0 my $self = shift;
659 0 my $dg = shift;
660 0 my $fh = shift;
661 0 my $x = shift;
662 0 my $y = shift;
663 0 my $diameter = shift;
664 0 my $a = 0.25 * $diameter;
665 0 my $b = 0.5 * sqrt(0.75) * $diameter;
666 0 print $fh "\\pgfpathmoveto{";
667 0 $dg->write_point($x, ($y + 0.5 * $diameter));
668 0 print $fh "}\n";
669 0 print $fh "\\pgfpathlineto{";
670 0 $dg->write_point(($x - $b), ($y - $a));
671 0 print $fh "}\n";
672 0 print $fh "\\pgfpathlineto{";
673 0 $dg->write_point(($x + $b), ($y - $a));
674 0 print $fh "}\n\\pgfpathclose\\pgfusepath{fill}\n";
675 0 return $self;
676 }
677  
678  
679  
680 sub dot_crosshair
681 0 ▶{
Subroutine dot_crosshair: not called CC=1 SCAR=6.9
Pod undocumented
682 0 my $self = shift;
683 0 my $dg = shift;
684 0 my $fh = shift;
685 0 my $x = shift;
686 0 my $y = shift;
687 0 my $diameter = shift;
688 0 print $fh "\\pgfpathmoveto{";
689 0 $dg->write_point($x, ($y + 0.5 * $diameter));
690 0 print $fh "}\n";
691 0 print $fh "\\pgfpathlineto{";
692 0 $dg->write_point($x, ($y - 0.5 * $diameter));
693 0 print $fh "}\n";
694 0 print $fh "\\pgfusepath{stroke}\n";
695 0 print $fh "\\pgfpathmoveto{";
696 0 $dg->write_point(($x - 0.5 * $diameter), $y);
697 0 print $fh "}\n";
698 0 print $fh "\\pgfpathlineto{";
699 0 $dg->write_point(($x + 0.5 * $diameter), $y);
700 0 print $fh "}\n\\pgfusepath{stroke}\n";
701 0 return $self;
702 }
703  
704  
705  
706 sub dot_pentagon
707 0 ▶{
Subroutine dot_pentagon: not called CC=1 SCAR=6.9
Pod undocumented
708 0 my $self = shift;
709 0 my $dg = shift;
710 0 my $fh = shift;
711 0 my $x = shift;
712 0 my $y = shift;
713 0 my $diameter = shift;
714 0 my $a = 0.5 * $diameter * cos(2.0 * 3.1415926 / 5.0);
715 0 my $b = 0.5 * $diameter * sin(2.0 * 3.1415926 / 5.0);
716 0 my $c = 0.5 * $diameter * cos(4.0 * 3.1415926 / 5.0);
717 0 my $d = 0.5 * $diameter * sin(4.0 * 3.1415926 / 5.0);
718 0 print $fh "\\pgfpathmoveto{";
719 0 $dg->write_point($x, ($y + 0.5 * $diameter));
720 0 print $fh "}\n";
721 0 print $fh "\\pgfpathlineto{";
722 0 $dg->write_point(($x - $b), ($y + $a));
723 0 print $fh "}\n";
724 0 print $fh "\\pgfpathlineto{";
725 0 $dg->write_point(($x - $d), ($y + $c));
726 0 print $fh "}\n";
727 0 print $fh "\\pgfpathlineto{";
728 0 $dg->write_point(($x + $d), ($y + $c));
729 0 print $fh "}\n";
730 0 print $fh "\\pgfpathlineto{";
731 0 $dg->write_point(($x + $b), ($y + $a));
732 0 print $fh "}\n\\pgfpathclose\\pgfusepath{fill}\n";
733 0 return $self;
734 }
735  
736  
737  
738 sub plot_points_points
739 0 ▶{
Subroutine plot_points_points: not called CC=9 SCAR=45.0
Pod undocumented
740 0 my $self = shift; my $dg = shift;
741 0 my $fh = $dg->{'f1'};
742 0 my $aref = $self->{'pp'};
743 0 my $pref = undef; my $x = undef; my $y = undef;
744 0 my $diameter = $self->{'dsz'} * 0.2 * 72.0 / 25.4;
745 0 ▶ if($#$aref > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($aref->$#* > 0) 0 0 0
746 0 ▶ for(my $i = 0; $i <= $#$aref; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $aref->$#*) 0 0 0
747 0 $pref = $aref->[$i];
748 0 $x = $pref->[0]; $y = $pref->[1];
749 0 $x = $self->{'ax'}->value_to_coord($x);
750 0 $y = $self->{'ay'}->value_to_coord($y);
751 0 my $dt = $self->{'ds'};
752 0 ▶ if($dt == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 0) 0 0 0
753 0 $self->dot_circle($dg, $fh, $x, $y, $diameter);
754 }
755 0 ▶ if($dt == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 1) 0 0 0
756 0 $self->dot_square($dg, $fh, $x, $y, $diameter);
757 }
758 0 ▶ if($dt == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 2) 0 0 0
759 0 $self->dot_diamond($dg, $fh, $x, $y, $diameter);
760 }
761 0 ▶ if($dt == 3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 3) 0 0 0
762 0 $self->dot_triangle($dg, $fh, $x, $y, $diameter);
763 }
764 0 ▶ if($dt == 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 4) 0 0 0
765 0 $self->dot_crosshair($dg, $fh, $x, $y, $diameter);
766 }
767 0 ▶ if($dt == 5) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 5) 0 0 0
768 0 $self->dot_pentagon($dg, $fh, $x, $y, $diameter);
769 }
770 }
771 }
772 0 return $self;
773 }
774  
775  
776  
777 sub plot_points_lines
778 0 ▶{
Subroutine plot_points_lines: not called CC=4 SCAR=30.0
Pod undocumented
779 0 my $self = shift; my $dg = shift;
780 0 my $fh = $dg->{'f1'};
781 0 my $aref = $self->{'pp'};
782 0 my $pref = undef; my $x = undef; my $y = undef;
783 0 ▶ if($#$aref > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($aref->$#* > 0) 0 0 0
784 0 ▶ for(my $i = 0; $i <= $#$aref; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $aref->$#*) 0 0 0
785 0 $pref = $aref->[$i];
786 0 $x = $pref->[0]; $y = $pref->[1];
787 0 $x = $self->{'ax'}->value_to_coord($x);
788 0 $y = $self->{'ay'}->value_to_coord($y);
789 0 ▶ if($i == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i == 0) { } 0 0 0
790 0 print $fh "\\pgfpathmoveto{";
791 } else {
792 0 print $fh "\\pgfpathlineto{";
793 }
794 0 $dg->write_point($x, $y);
795 0 print $fh "}\n";
796 }
797 0 print $fh "\\pgfusepath{stroke}\n";
798 }
799 0 return $self;
800 }
801  
802  
803  
804 sub all_values_with_derivative
805 0 ▶{
Subroutine all_values_with_derivative: not called CC=2 SCAR=17.9
Pod undocumented
806 0 my $self = shift; my $dg = shift; my $pp = shift; my $fh = $dg->{'f1'};
807 0 my $pref = $pp->[0];
808 0 my $x = $pref->[0];
809 0 my $y = $pref->[1];
810 0 my $z = $pref->[2];
811 0 my $ox = $x; my $oy = $y; my $oz = $z; my $dxdt = undef; my $dydt = undef;
812 0 print $fh "\\pgfpathmoveto{";
813 0 $dg->write_point($x, $y);
814 0 print $fh "}\n";
815 0 ▶ for(my $i = 1; $i <= $#$pp; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $pp->$#*) 0 0 0
816 0 $pref = $pp->[$i];
817 0 $x = $pref->[0]; $y = $pref->[1]; $z = $pref->[2];
818 0 $dxdt = $x - $ox;
819 0 print $fh "\\pgfpathcurveto{";
820 0 $dydt = $oz * $dxdt;
821 0 $dg->write_point(($ox + ($dxdt/3.0)), ($oy + ($dydt/3.0)));
822 0 print $fh "}{";
823 0 $dydt = $z * $dxdt;
824 0 $dg->write_point(($x - ($dxdt/3.0)), ($y - ($dydt/3.0)));
825 0 print $fh "}{";
826 0 $dg->write_point($x, $y);
827 0 print $fh "}\n";
828 0 $ox = $x; $oy = $y; $oz = $z;
829 }
830 0 print $fh "\\pgfusepath{stroke}\n";
831 0 return $self;
832 }
833  
834  
835  
836 sub some_values_without_derivative
837 0 ▶{
Subroutine some_values_without_derivative: not called CC=12 SCAR=50.5
Pod undocumented
838 0 my $self = shift; my $dg = shift; my $pp = shift;
839 0 my $N = $#$pp + 1; # Number of points
840 0 my $nsegs = $N - 1; # Number of segments
841 0 my $neqs = 4 * $nsegs; # Number of equations and coefficients
842 0 my $eqnno; # Current equation
843 my $pref; # Reference to current point
844 0 my $j; # Number index
845 0 my $i; # Index of pref
846 0 my $x; # X coordinate
847 0 my $y; # Y coordinate
848 0 my $z; # first derivative (dy/dx)
849 0 my $mtx = zeros($neqs, $neqs); # Coefficients of eq sys
850 0 my $rve = zeros(1, $neqs); # Results vector of eq sys
851 # nsegs: 0 ... nsegs-1
852 0 ▶ for($j = 0; $j < $nsegs; $j++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j < $nsegs) 0 0 0
853 0 $eqnno = $j; $i = $j;
854 0 $pref = $pp->[$i]; $x = $pref->[0]; $y = $pref->[1];
855 0 $rve->set(0, $eqnno, $y);
856 0 $mtx->set((4*$j), $eqnno, ($x * $x * $x));
857 0 $mtx->set((4*$j+1), $eqnno, ($x * $x));
858 0 $mtx->set((4*$j+2), $eqnno, $x);
859 0 $mtx->set((4*$j+3), $eqnno, 1.0);
860 }
861 # nsegs: nsegs ... 2*nsegs-1
862 0 ▶ for($j = 0; $j < $nsegs; $j++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j < $nsegs) 0 0 0
863 0 $eqnno = $nsegs + $j; $i = $j + 1;
864 0 $pref = $pp->[$i]; $x = $pref->[0]; $y = $pref->[1];
865 0 $rve->set(0, $eqnno, $y);
866 0 $mtx->set((4*$j), $eqnno, ($x * $x * $x));
867 0 $mtx->set((4*$j+1), $eqnno, ($x * $x));
868 0 $mtx->set((4*$j+2), $eqnno, $x);
869 0 $mtx->set((4*$j+3), $eqnno, 1.0);
870 }
871 # nsegs-1: 2*nsegs ... 3*nsegs-2
872 0 ▶ for($j = 0; $j < ($nsegs - 1); $j++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j < $nsegs - 1) 0 0 0
873 0 $eqnno = 2 * $nsegs + $j; $i = $j + 1;
874 0 $pref = $pp->[$i]; $x = $pref->[0]; $y = $pref->[1];
875 0 $mtx->set((4*$j), $eqnno, (3.0 * $x * $x));
876 0 $mtx->set((4*$j+1), $eqnno, (2.0 * $x));
877 0 $mtx->set((4*$j+2), $eqnno, 1.0);
878 0 $mtx->set((4*$i), $eqnno, (-3.0 * $x * $x));
879 0 $mtx->set((4*$i+1), $eqnno, (-2.0 * $x));
880 0 $mtx->set((4*$i+2), $eqnno, -1.0);
881 }
882 # nsegs-1: 3*nsegs-1 ... 4*nsegs-3
883 0 ▶ for($j = 0; $j < ($nsegs - 1); $j++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j < $nsegs - 1) 0 0 0
884 0 $eqnno = 3 * $nsegs - 1 + $j; $i = $j + 1;
885 0 $pref = $pp->[$i]; $x = $pref->[0]; $y = $pref->[1];
886 0 ▶ if($#$pref > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pref->$#* > 1) { } 0 0 0
887 0 $z = $pref->[2];
888 0 $mtx->set((4*$j), $eqnno, (3.0 * $x * $x));
889 0 $mtx->set((4*$j+1), $eqnno, (2.0 * $x));
890 0 $mtx->set((4*$j+2), $eqnno, 1.0);
891 0 $rve->set(0, $eqnno, $z);
892 } else {
893 0 $mtx->set((4*$j), $eqnno, (6.0 * $x));
894 0 $mtx->set((4*$j+1), $eqnno, 2.0);
895 0 $mtx->set((4*$i), $eqnno, (-6.0 * $x));
896 0 $mtx->set((4*$i+1), $eqnno, -2.0);
897 }
898 }
899 # 4*nsegs-2
900 0 $eqnno = 4 * $nsegs - 2; $j = 0; $i = 0;
901 0 $pref = $pp->[$i]; $x = $pref->[0]; $y = $pref->[1];
902 0 ▶ if($#$pref > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pref->$#* > 1) { } 0 0 0
903 0 $z = $pref->[2];
904 0 $mtx->set((4*$j), $eqnno, (3.0 * $x * $x));
905 0 $mtx->set((4*$j+1), $eqnno, (2.0 * $x));
906 0 $mtx->set((4*$j+2), $eqnno, 1.0);
907 0 $rve->set(0, $eqnno, $z);
908 } else {
909 0 $mtx->set((4*$j), $eqnno, (6.0 * $x));
910 0 $mtx->set((4*$j+1), $eqnno, 2.0);
911 }
912 # 4*nsegs-1
913 0 $eqnno = 4 * $nsegs - 1; $j = $nsegs - 1; $i = $j + 1;
914 0 $pref = $pp->[$i]; $x = $pref->[0]; $y = $pref->[1];
915 0 ▶ if($#$pref > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pref->$#* > 1) { } 0 0 0
916 0 $z = $pref->[2];
917 0 $mtx->set((4*$j), $eqnno, (3.0 * $x * $x));
918 0 $mtx->set((4*$j+1), $eqnno, (2.0 * $x));
919 0 $mtx->set((4*$j+2), $eqnno, 1.0);
920 0 $rve->set(0, $eqnno, $z);
921 } else {
922 0 $mtx->set((4*$j), $eqnno, (6.0 * $x));
923 0 $mtx->set((4*$j+1), $eqnno, 2.0);
924 }
925 0 my $res = $mtx->inv() x $rve;
926 0 ▶ if($self->{'debug'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"debug"}) 0 0 0
927 0 print $res;
928 }
929 0 my @ppb; my $nppb = 0;
930 0 ▶ for($i = 0; $i <= $#$pp; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $pp->$#*) 0 0 0
931 0 $pref = $pp->[$i];
932 0 $x = $pref->[0]; $y = $pref->[1]; $z = 0.0;
933 0 ▶ if($#$pref > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pref->$#* > 1) { } 0 0 0
934 0 $z = $pref->[2];
935 } else {
936 0 ▶ if($i > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i > 0) { } 0 0 0
937 0 $z = 3.0 * $res->at(0, 4*($i-1)) * $x * $x
938 + 2.0 * $res->at(0, 4*($i-1)+1) * $x
939 + $res->at(0, 4*($i-1)+2);
940 } else {
941 0 $z = 3.0 * $res->at(0, 0) * $x * $x
942 + 2.0 * $res->at(0, 1) * $x
943 + $res->at(0, 2);
944 }
945 }
946 0 $ppb[$i] = [ $x, $y, $z ];
947 }
948 0 $self->all_values_with_derivative($dg, \@ppb);
949 0 return $self;
950 }
951  
952  
953  
954 sub plot_points_curve
955 0 ▶{
Subroutine plot_points_curve: not called CC=5 SCAR=34.0
Pod undocumented
956 0 my $self = shift; my $dg = shift;
957 0 my @ppa; my $nppa = 0;
958 0 my $aref = $self->{'pp'};
959 0 my $pref = undef;
960 0 my $ax = $self->{'ax'}; my $ay = $self->{'ay'};
961 0 my $x = undef;
962 0 my $y = undef;
963 0 my $z = undef;
964 0 my $value_without_derivative = 0;
965 0 ▶ for(my $i = 0; $i <= $#$aref; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $aref->$#*) 0 0 0
966 0 $pref = $aref->[$i];
967 0 $z = undef;
968 0 $x = $pref->[0]; $y = $pref->[1];
969 0 ▶ if($#$pref > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pref->$#* > 1) { } 0 0 0
970 0 $z = $pref->[2]
971 * $ay->value_to_derivative($y) / $ax->value_to_derivative($x);
972 } else {
973 0 $value_without_derivative = 1;
974 }
975 0 $x = $self->{'ax'}->value_to_coord($x);
976 0 $y = $self->{'ay'}->value_to_coord($y);
977 0 ▶ if(defined($z)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $z) { } 0 0 0
978 0 $ppa[$nppa++] = [ $x, $y, $z ];
979 } else {
980 0 $ppa[$nppa++] = [ $x, $y ];
981 }
982 }
983 0 my @ppb = sort { $a->[0] <=> $b->[0]; } @ppa;
984 0 ▶ if($value_without_derivative) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value_without_derivative) { } 0 0 0
985 0 $self->some_values_without_derivative($dg, \@ppb);
986 } else {
987 0 $self->all_values_with_derivative($dg, \@ppb);
988 }
989 0 return $self;
990 }
991  
992  
993  
994 sub plot_param_points
995 0 ▶{
Subroutine plot_param_points: not called CC=8 SCAR=42.8
Pod undocumented
996 0 my $self = shift; my $dg = shift; my $fh = $dg->{'f1'};
997 0 my $ar = $self->{'pp'};
998 0 my $pr = undef;
999 0 my $x = undef;
1000 0 my $y = undef;
1001 0 my $dt = $self->{'ds'};
1002 0 my $diameter = $self->{'dsz'} * 0.2 * 72.0 / 25.4;
1003 0 ▶ for(my $i = 0; $i <= $#$ar; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $ar->$#*) 0 0 0
1004 0 $pr = $ar->[$i];
1005 0 $x = $pr->[1];
1006 0 $y = $pr->[2];
1007 0 $x = $self->{'ax'}->value_to_coord($x);
1008 0 $y = $self->{'ay'}->value_to_coord($y);
1009 0 ▶ if($dt == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 0) 0 0 0
1010 0 $self->dot_circle($dg, $fh, $x, $y, $diameter);
1011 }
1012 0 ▶ if($dt == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 1) 0 0 0
1013 0 $self->dot_square($dg, $fh, $x, $y, $diameter);
1014 }
1015 0 ▶ if($dt == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 2) 0 0 0
1016 0 $self->dot_diamond($dg, $fh, $x, $y, $diameter);
1017 }
1018 0 ▶ if($dt == 3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 3) 0 0 0
1019 0 $self->dot_triangle($dg, $fh, $x, $y, $diameter);
1020 }
1021 0 ▶ if($dt == 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 4) 0 0 0
1022 0 $self->dot_crosshair($dg, $fh, $x, $y, $diameter);
1023 }
1024 0 ▶ if($dt == 5) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 5) 0 0 0
1025 0 $self->dot_pentagon($dg, $fh, $x, $y, $diameter);
1026 }
1027 }
1028 0 return $self;
1029 }
1030  
1031  
1032  
1033 sub plot_param_lines
1034 0 ▶{
Subroutine plot_param_lines: not called CC=3 SCAR=24.8
Pod undocumented
1035 0 my $self = shift; my $dg = shift; my $fh = $dg->{'f1'};
1036 0 my $ar = $self->{'pp'};
1037 0 my $pr = undef;
1038 0 my $x = undef;
1039 0 my $y = undef;
1040 0 ▶ if($#$ar >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ar->$#* >= 1) 0 0 0
1041 0 $pr = $ar->[0];
1042 0 $x = $self->{'ax'}->value_to_coord($pr->[1]);
1043 0 $y = $self->{'ax'}->value_to_coord($pr->[2]);
1044 0 print $fh "\\pgfpathmoveto{";
1045 0 $dg->write_point($x, $y);
1046 0 print $fh "}\n";
1047 0 ▶ for(my $i = 1; $i <= $#$ar; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $ar->$#*) 0 0 0
1048 0 $pr = $ar->[$i];
1049 0 $x = $self->{'ax'}->value_to_coord($pr->[1]);
1050 0 $y = $self->{'ax'}->value_to_coord($pr->[2]);
1051 0 print $fh "\\pgfpathlineto{";
1052 0 $dg->write_point($x, $y);
1053 0 print $fh "}\n";
1054 }
1055 0 print $fh "\\pgfusepath{stroke}\n";
1056 }
1057 0 return $self;
1058 }
1059  
1060  
1061  
1062 sub check_param_derivatives
1063 0 ▶{
Subroutine check_param_derivatives: not called CC=4 SCAR=30.0
Pod undocumented
1064 0 my $self = shift;
1065 0 my $back = 1;
1066 0 my $ar; my $pr;
1067 0 $ar = $self->{'pp'};
1068 0 ▶ for(my $i = 0; $i <= $#$ar; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $ar->$#*) 0 0 0
1069 0 $pr = $ar->[$i];
1070 0 ▶ if(!(defined($pr->[3]) && defined($pr->[4]))) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pr->[3] and defined $pr->[4]) 0 0 0
Condition0%0/3
defined $pr->[3] and defined $pr->[4]
!ll&&!rl&&r
000
MC/DC0%0/2
defined $pr->[3] and defined $pr->[4]
defined $pr->[3] defined $pr->[4]
Truth table0%0/3
A and B
A= defined $pr->[3]B= defined $pr->[4]
ABresult
0X0
100
111
1071 0 $back = 0; $i = $#$ar + 1;
1072 }
1073 }
1074 0 return $back;
1075 }
1076  
1077  
1078  
1079 sub do_param_with_all_derivatives
1080 0 ▶{
Subroutine do_param_with_all_derivatives: not called CC=2 SCAR=17.9
Pod undocumented
1081 0 my $self = shift;
1082 0 my $dg = shift;
1083 0 my $pp = shift;
1084 0 my $fh = $dg->{'f1'};
1085 0 my $ox; my $oy; my $odxdt; my $odydt; my $x; my $y; my $dxdt; my $dydt;
1086 0 my $pr;
1087 0 $pr = $pp->[0];
1088 0 $x = $pr->[1]; $y = $pr->[2]; $dxdt = $pr->[3]; $dydt = $pr->[4];
1089 0 print $fh "\\pgfpathmoveto{";
1090 0 $dg->write_point($x, $y);
1091 0 print $fh "}\n";
1092 0 $ox = $x; $oy = $y; $odxdt = $dxdt; $odydt = $dydt;
1093 0 ▶ for(my $i = 1; $i <= $#$pp; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $pp->$#*) 0 0 0
1094 0 $pr = $pp->[$i];
1095 0 $x = $pr->[1]; $y = $pr->[2]; $dxdt = $pr->[3]; $dydt = $pr->[4];
1096 0 print $fh "\\pgfpathcurveto{";
1097 0 $dg->write_point(($ox + $odxdt/3.0), ($oy + $odydt/3.0));
1098 0 print $fh "}{";
1099 0 $dg->write_point(($x - $dxdt/3.0), ($y - $dydt/3.0));
1100 0 print $fh "}{";
1101 0 $dg->write_point($x, $y);
1102 0 print $fh "}\n";
1103 0 $ox = $x; $oy = $y; $odxdt = $dxdt; $odydt = $dydt;
1104 }
1105 0 print $fh "\\pgfusepath{stroke}\n";
1106 0 return $self;
1107 }
1108  
1109  
1110 sub param_with_all_derivatives
1111 0 ▶{
Subroutine param_with_all_derivatives: not called CC=2 SCAR=17.9
Pod undocumented
1112 0 my $self = shift; my $dg = shift;
1113 0 my $fh = $dg->{'f1'};
1114 0 my @npp;
1115 0 my $ar = $self->{'pp'};
1116 0 my $pr;
1117 0 my $t; my $x; my $y; my $xx; my $yy;
1118 0 my $r = $self->{'r'};
1119 0 my $mint = $r->[0]; my $maxt = $r->[1];
1120 0 my $dTdt = ($maxt - $mint) / (1.0 * $self->{'i'});
1121 0 my $ax = $self->{'ax'}; my $ay = $self->{'ay'};
1122 0 ▶ for(my $i = 0; $i <= $#$ar; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $ar->$#*) 0 0 0
1123 0 $pr = $ar->[$i];
1124 0 $t = $pr->[0]; $x = $pr->[1]; $y = $pr->[2]; $xx = $pr->[3]; $yy = $pr->[4];
1125 0 $xx = $xx * $ax->value_to_derivative($x) * $dTdt;
1126 0 $yy = $yy * $ay->value_to_derivative($y) * $dTdt;
1127 0 $x = $ax->value_to_coord($x);
1128 0 $y = $ay->value_to_coord($y);
1129 0 $npp[$i] = [ $t, $x, $y, $xx, $yy ];
1130 }
1131 0 $self->do_param_with_all_derivatives($dg, \@npp);
1132 0 return $self;
1133 }
1134  
1135  
1136  
1137 sub find_missing_derivatives
1138 0 ▶{
Subroutine find_missing_derivatives: not called CC=7 SCAR=40.3
Pod undocumented
1139 0 my $self = shift; my $dg = shift; my $pp = $self->{'pp'};
1140 0 my @npp;
1141 my $pr;
1142 0 my $t; my $x; my $y; my $xx; my $yy;
1143 0 my $N = $#$pp + 1;
1144 0 my $nsegs = $N - 1;
1145 0 my $ax = $self->{'ax'}; my $ay = $self->{'ay'};
1146 0 my $i;
1147 my $eqnno;
1148 0 ▶ for($i = 0; $i <= $#$pp; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $pp->$#*) 0 0 0
1149 0 $pr = $pp->[$i];
1150 0 $t = $pr->[0]; $x = $pr->[1]; $y = $pr->[2]; $xx = undef; $yy = undef;
1151 0 $x = $ax->value_to_coord($x);
1152 0 $y = $ay->value_to_coord($y);
1153 0 $npp[$i] = [ (1.0 * $i) , $x, $y, $xx, $yy ];
1154 }
1155 0 my $xmtx = zeros((4 * $nsegs), (4 * $nsegs));
1156 0 my $ymtx = zeros((4 * $nsegs), (4 * $nsegs));
1157 0 my $xres = zeros(1, (4 * $nsegs));
1158 0 my $yres = zeros(1, (4 * $nsegs));
1159 0 ▶ for($i = 0; $i < $nsegs; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $nsegs) 0 0 0
1160 0 $eqnno = $i;
1161 0 $pr = $npp[$i];
1162 0 $t = $pr->[0]; $x = $pr->[1]; $y = $pr->[2];
1163 0 $xres->set(0, $eqnno, $x);
1164 0 $xmtx->set((4 * $i), $eqnno, ($t*$t*$t));
1165 0 $xmtx->set((4 * $i + 1), $eqnno, ($t * $t));
1166 0 $xmtx->set((4 * $i + 2), $eqnno, $t);
1167 0 $xmtx->set((4 * $i + 3), $eqnno, 1.0);
1168 0 $yres->set(0, $eqnno, $y);
1169 0 $ymtx->set((4 * $i), $eqnno, ($t * $t * $t));
1170 0 $ymtx->set((4 * $i + 1), $eqnno, ($t * $t));
1171 0 $ymtx->set((4 * $i + 2), $eqnno, $t);
1172 0 $ymtx->set((4 * $i + 3), $eqnno, 1.0);
1173 }
1174 0 ▶ for($i = 0; $i < $nsegs; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $nsegs) 0 0 0
1175 0 $eqnno = $nsegs + $i;
1176 0 $pr = $npp[$i + 1];
1177 0 $t = $pr->[0]; $x = $pr->[1]; $y = $pr->[2];
1178 0 $xres->set(0, $eqnno, $x);
1179 0 $xmtx->set((4 * $i), $eqnno, ($t * $t * $t));
1180 0 $xmtx->set((4 * $i + 1), $eqnno, ($t * $t));
1181 0 $xmtx->set((4 * $i + 2), $eqnno, $t);
1182 0 $xmtx->set((4 * $i + 3), $eqnno, 1.0);
1183 0 $yres->set(0, $eqnno, $y);
1184 0 $ymtx->set((4 * $i), $eqnno, ($t * $t * $t));
1185 0 $ymtx->set((4 * $i + 1), $eqnno, ($t * $t));
1186 0 $ymtx->set((4 * $i + 2), $eqnno, $t);
1187 0 $ymtx->set((4 * $i + 3), $eqnno, 1.0);
1188 }
1189 0 ▶ for($i = 0; $i < ($nsegs - 1); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $nsegs - 1) 0 0 0
1190 0 $eqnno = 2 * $nsegs + $i;
1191 0 $pr = $npp[$i + 1];
1192 0 $t = $pr->[0]; $x = $pr->[1]; $y = $pr->[2];
1193 0 $xmtx->set((4 * $i), $eqnno, (3.0 * $t * $t));
1194 0 $xmtx->set((4 * $i + 1), $eqnno, (2.0 * $t));
1195 0 $xmtx->set((4 * $i + 2), $eqnno, 1.0);
1196 0 $xmtx->set((4 * ($i + 1)), $eqnno, (-3.0 * $t * $t));
1197 0 $xmtx->set((4 * ($i + 1) + 1), $eqnno, (-2.0 * $t));
1198 0 $xmtx->set((4 * ($i + 1) + 2), $eqnno, -1.0);
1199 0 $ymtx->set((4 * $i), $eqnno, (3.0 * $t * $t));
1200 0 $ymtx->set((4 * $i + 1), $eqnno, (2.0 * $t));
1201 0 $ymtx->set((4 * $i + 2), $eqnno, 1.0);
1202 0 $ymtx->set((4 * ($i + 1)), $eqnno, (-3.0 * $t * $t));
1203 0 $ymtx->set((4 * ($i + 1) + 1), $eqnno, (-2.0 * $t));
1204 0 $ymtx->set((4 * ($i + 1) + 2), $eqnno, -1.0);
1205 }
1206 0 ▶ for($i = 0; $i < ($nsegs - 1); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $nsegs - 1) 0 0 0
1207 0 $eqnno = 3 * $nsegs - 1 + $i;
1208 0 $pr = $npp[$i + 1];
1209 0 $t = $pr->[0]; $x = $pr->[1]; $y = $pr->[2];
1210 0 $xmtx->set((4 * $i), $eqnno, (6.0 * $t));
1211 0 $xmtx->set((4 * $i + 1), $eqnno, 2.0);
1212 0 $xmtx->set((4 * ($i + 1)), $eqnno, (-6.0 * $t));
1213 0 $xmtx->set((4 * ($i + 1) + 1), $eqnno, -2.0);
1214 0 $ymtx->set((4 * $i), $eqnno, (6.0 * $t));
1215 0 $ymtx->set((4 * $i + 1), $eqnno, 2.0);
1216 0 $ymtx->set((4 * ($i + 1)), $eqnno, (-6.0 * $t));
1217 0 $ymtx->set((4 * ($i + 1) + 1), $eqnno, -2.0);
1218 }
1219 0 $i = 0; $eqnno = 4 * $nsegs - 2;
1220 0 $pr = $npp[0];
1221 0 $t = $pr->[0]; $x = $pr->[1]; $y = $pr->[2];
1222 0 $xmtx->set((4 * $i), $eqnno, (6.0 * $t));
1223 0 $xmtx->set((4 * $i + 1), $eqnno, 2.0);
1224 0 $ymtx->set((4 * $i), $eqnno, (6.0 * $t));
1225 0 $ymtx->set((4 * $i + 1), $eqnno, 2.0);
1226 0 $i = $nsegs - 1; $eqnno = 4 * $nsegs - 1;
1227 0 $pr = $npp[$nsegs];
1228 0 $t = $pr->[0]; $x = $pr->[1]; $y = $pr->[2];
1229 0 $xmtx->set((4 * $i), $eqnno, (6.0 * $t));
1230 0 $xmtx->set((4 * $i + 1), $eqnno, 2.0);
1231 0 $ymtx->set((4 * $i), $eqnno, (6.0 * $t));
1232 0 $ymtx->set((4 * $i + 1), $eqnno, 2.0);
1233 0 my $xco = $xmtx->inv() x $xres;
1234 0 my $yco = $ymtx->inv() x $yres;
1235 0 ▶ for($i = 0; $i < $#npp; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $#npp) 0 0 0
1236 0 $pr = $npp[$i];
1237 0 $t = $pr->[0]; $x = $pr->[1]; $y = $pr->[2];
1238 0 $xx = 3.0 * $xco->at(0, (4 * $i)) * $t * $t
1239 + 2.0 * $xco->at(0, (4 * $i + 1)) * $t
1240 + $xco->at(0, (4 * $i + 2));
1241 0 $yy = 3.0 * $yco->at(0, (4 * $i)) * $t * $t
1242 + 2.0 * $yco->at(0, (4 * $i + 1)) * $t
1243 + $yco->at(0, (4 * $i + 2));
1244 0 $pr->[3] = $xx; $pr->[4] = $yy;
1245 }
1246 0 $i = $#npp - 1;
1247 0 $pr = $npp[ $#npp ];
1248 0 $t = $pr->[0]; $x = $pr->[1]; $y = $pr->[2];
1249 0 $xx = 3.0 * $xco->at(0, (4 * $i)) * $t * $t
1250 + 2.0 * $xco->at(0, (4 * $i + 1)) * $t
1251 + $xco->at(0, (4 * $i + 2));
1252 0 $yy = 3.0 * $yco->at(0, (4 * $i)) * $t * $t
1253 + 2.0 * $yco->at(0, (4 * $i + 1)) * $t
1254 + $yco->at(0, (4 * $i + 2));
1255 0 $pr->[3] = $xx; $pr->[4] = $yy;
1256 0 $self->do_param_with_all_derivatives($dg, \@npp);
1257 }
1258  
1259  
1260  
1261 sub plot_param_curve
1262 0 ▶{
Subroutine plot_param_curve: not called CC=2 SCAR=17.9
Pod undocumented
1263 0 my $self = shift; my $dg = shift;
1264 0 ▶ if($self->check_param_derivatives($dg)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->check_param_derivatives($dg)) { } 0 0 0
1265 0 $self->param_with_all_derivatives($dg);
1266 } else {
1267 0 $self->find_missing_derivatives($dg);
1268 }
1269 0 return $self;
1270 }
1271  
1272  
1273  
1274 sub plot_xspline_curve
1275 0 ▶{
Subroutine plot_xspline_curve: not called CC=8 SCAR=42.8
Pod undocumented
1276 0 my $self = shift;
1277 0 my $dg = shift;
1278 0 my $fh = $dg->{'f1'};
1279 0 my $xs = LaTeX::PGF::Diagram2D::Xspline->new();
1280 0 my @pp; my $npp = 0;
1281 0 my $ar = $self->{'pp'};
1282 0 my $ax = $self->{'ax'};
1283 0 my $ay = $self->{'ay'};
1284 0 my $x;
1285 my $y;
1286 0 my $s;
1287 0 my $dxdt;
1288 0 my $dydt;
1289 0 my $odxdt;
1290 0 my $odydt;
1291 0 my $ox;
1292 0 my $oy;
1293 0 my $b; # Current start point of segment
1294 0 my $a; # Left neighbour
1295 0 my $c; # Current end point of segment
1296 0 my $d; # Right neighbour
1297 0 my $pa; my $pb; my $pc; my $pd;
1298 0 ▶ for($npp = 0; $npp <= $#$ar; $npp++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($npp <= $ar->$#*) 0 0 0
1299 0 $pa = $ar->[$npp];
1300 0 $x = $pa->[0]; $y = $pa->[1];
1301 0 $s = -1.0;
1302 0 ▶ if($#$pa > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pa->$#* > 1) 0 0 0
1303 0 $s = $pa->[2];
1304 }
1305 0 $x = $ax->value_to_coord($x);
1306 0 $y = $ay->value_to_coord($y);
1307 0 $pp[$npp] = [ $x, $y, $s ];
1308 }
1309 0 $ar = \@pp;
1310 0 my $subs = $self->{'xspline'}; ; my $i; my $t;
1311 0 ▶ for($b = 0; $b < $#pp; $b++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($b < $#pp) 0 0 0
1312 0 $a = $b - 1; $c = $b + 1; $d = $b + 2;
1313 0 $pa = undef; $pb = undef; $pc = undef; $pd = undef;
1314 0 ▶ if($a >= 0) { $pa = $pp[$a]; }
Branch: 1 branch
BranchTrueFalseTotal
if ($a >= 0) 0 0 0
1315 0 $pb = $pp[$b];
1316 0 $pc = $pp[$c];
1317 0 ▶ if($d <= $#pp) { $pd = $pp[$d]; }
Branch: 1 branch
BranchTrueFalseTotal
if ($d <= $#pp) 0 0 0
1318 0 $xs->set_points($pa, $pb, $pc, $pd);
1319 0 $xs->calculate(0.0);
1320 0 $odxdt = $xs->{'ddtx'} / (1.0 * $subs);
1321 0 $odydt = $xs->{'ddty'} / (1.0 * $subs);
1322 0 $ox = $xs->{'x'}; my $oy = $xs->{'y'};
1323 0 ▶ if($b == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($b == 0) 0 0 0
1324 0 print $fh "\\pgfpathmoveto{";
1325 0 $dg->write_point($ox, $oy);
1326 0 print $fh "}\n";
1327 }
1328 0 ▶ for($i = 1; $i < $subs; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $subs) 0 0 0
1329 0 $t = (1.0 * $i) / (1.0 * $subs);
1330 0 $xs->calculate($t);
1331 0 $x = $xs->{'x'}; $y = $xs->{'y'};
1332 0 $dxdt = $xs->{'ddtx'} / (1.0 * $subs);
1333 0 $dydt = $xs->{'ddty'} / (1.0 * $subs);
1334 0 print $fh "\\pgfpathcurveto{\n";
1335 0 $dg->write_point(($ox + ($odxdt / 3.0)), ($oy + ($odydt / 3.0)));
1336 0 print $fh "}{";
1337 0 $dg->write_point(($x - ($dxdt / 3.0)), ($y - ($dydt / 3.0)));
1338 0 print $fh "}{";
1339 0 $dg->write_point($x, $y);
1340 0 print $fh "}\n";
1341 0 $ox = $x; $oy = $y; $odxdt = $dxdt; $odydt = $dydt;
1342 }
1343 0 $t = 1.0;
1344 0 $xs->calculate($t);
1345 0 $x = $xs->{'x'}; $y = $xs->{'y'};
1346 0 $dxdt = $xs->{'ddtx'} / (1.0 * $subs);
1347 0 $dydt = $xs->{'ddty'} / (1.0 * $subs);
1348 0 print $fh "\\pgfpathcurveto{\n";
1349 0 $dg->write_point(($ox + ($odxdt / 3.0)), ($oy + ($odydt / 3.0)));
1350 0 print $fh "}{";
1351 0 $dg->write_point(($x - ($dxdt / 3.0)), ($y - ($dydt / 3.0)));
1352 0 print $fh "}{";
1353 0 $dg->write_point($x, $y);
1354 0 print $fh "}\n";
1355 0 $ox = $x; $oy = $y; $odxdt = $dxdt; $odydt = $dydt;
1356 }
1357 0 print $fh "\\pgfusepath{stroke}\n";
1358 }
1359  
1360  
1361  
1362 sub plot_to
1363 0 ▶{
Subroutine plot_to: not called CC=18 SCAR=58.3
Pod undocumented
1364 0 my $self = undef;
1365 0 ▶ if($#_ < 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ < 1) { } 0 0 0
1366 0 croak "Usage: \$plot->plot_to(diagram)";
1367 } else {
1368 0 $self = shift; my $dg = shift;
1369 0 $self->finish();
1370 0 my $color = 'black';
1371 0 ▶ if(defined($self->{'color'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"color"}) 0 0 0
1372 0 $color = $self->{'color'};
1373 }
1374 0 $dg->set_color($color);
1375 0 my $pt = $self->{'t'};
1376 0 my $dt = $self->{'d'};
1377 0 ▶ if($pt == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pt == 0) { } 0 0 0
1378 0 ▶ if($dt == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 0) { } 0 0 0
1379 0 $self->plot_points_points($dg);
1380 } else {
1381 0 ▶ if($dt == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 1) { } 0 0 0
1382 0 $self->plot_points_points($dg);
1383 } else {
1384 0 ▶ if($dt == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 2) { } 0 0 0
1385 0 $self->plot_param_points($dg);
1386 } else {
1387 0 ▶ if($dt == 3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 3) 0 0 0
1388 0 $self->plot_points_points($dg);
1389 }
1390 }
1391 }
1392 }
1393 } else {
1394 0 ▶ if($pt == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pt == 1) { } 0 0 0
1395 0 ▶ if($dt == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 0) { } 0 0 0
1396 0 $self->plot_points_curve($dg);
1397 } else {
1398 0 ▶ if($dt == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 1) { } 0 0 0
1399 0 $self->plot_points_curve($dg);
1400 } else {
1401 0 ▶ if($dt == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 2) { } 0 0 0
1402 0 $self->plot_param_curve($dg);
1403 } else {
1404 0 ▶ if($dt == 3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 3) 0 0 0
1405 0 $self->plot_xspline_curve($dg);
1406 }
1407 }
1408 }
1409 }
1410 } else {
1411 0 ▶ if($pt == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pt == 2) 0 0 0
1412 0 ▶ if($dt == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 0) { } 0 0 0
1413 0 $self->plot_points_lines($dg);
1414 } else {
1415 0 ▶ if($dt == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 1) { } 0 0 0
1416 0 $self->plot_points_lines($dg);
1417 } else {
1418 0 ▶ if($dt == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 2) { } 0 0 0
1419 0 $self->plot_param_lines($dg);
1420 } else {
1421 0 ▶ if($dt == 3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt == 3) 0 0 0
1422 0 $self->plot_points_lines($dg);
1423 }
1424 }
1425 }
1426 }
1427 }
1428 }
1429 }
1430 }
1431 0 return $self;
1432 }
1433  
1434  
1435 sub set_curve
1436 0 ▶{
Subroutine set_curve: not called CC=2 SCAR=17.9
Pod undocumented
1437 0 my $self = undef;
1438 0 ▶ if($#_ < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ < 0) { } 0 0 0
1439 0 croak "Usage: \$plot->set_lines()";
1440 } else {
1441 0 $self = shift; $self->{'t'} = 1;
1442 }
1443 0 return $self;
1444 }
1445  
1446  
1447 sub set_lines
1448 0 ▶{
Subroutine set_lines: not called CC=2 SCAR=17.9
Pod undocumented
1449 0 my $self = undef;
1450 0 ▶ if($#_ < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ < 0) { } 0 0 0
1451 0 croak "Usage: \$plot->set_lines()";
1452 } else {
1453 0 $self = shift; $self->{'t'} = 2;
1454 }
1455 0 return $self;
1456 }
1457  
1458  
1459  
1460 sub set_dots
1461 0 ▶{
Subroutine set_dots: not called CC=22 SCAR=62.3
Pod undocumented
1462 0 my $self = undef;
1463 0 ▶ if($#_ < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ < 0) { } 0 0 0
1464 0 croak "Usage: \$plot->set_dots([dotstyle])";
1465 } else {
1466 0 $self = shift; $self->{'t'} = 0; $self->{'ds'} = 0;
1467 0 ▶ if($#_ >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ >= 0) 0 0 0
1468 0 my $t = shift;
1469 0 ▶ if(("$t" eq "0") || ("$t" eq "c") || ("$t" eq "circle")) {
Branch: 1 branch
BranchTrueFalseTotal
if ("$t" eq 0 or "$t" eq "c" or "$t" eq "circle") 0 0 0
Condition0%0/6
"$t" eq 0 or "$t" eq "c" or "$t" eq "circle"
l!l&&r!l&&!r
000
"$t" eq 0 or "$t" eq "c"
l!l&&r!l&&!r
000
MC/DC0%0/3
"$t" eq 0 or "$t" eq "c" or "$t" eq "circle"
"$t" eq 0 "$t" eq "c" "$t" eq "circle"
Truth table0%0/4
A or B or C
A= "$t" eq 0B= "$t" eq "c"C= "$t" eq "circle"
ABCresult
1XX1
01X1
0011
0000
1470 0 $self->{'ds'} = 0;
1471 }
1472 0 ▶ if(("$t" eq "1") || ("$t" eq "s") || ("$t" eq "square")) {
Branch: 1 branch
BranchTrueFalseTotal
if ("$t" eq 1 or "$t" eq "s" or "$t" eq "square") 0 0 0
Condition0%0/6
"$t" eq 1 or "$t" eq "s" or "$t" eq "square"
l!l&&r!l&&!r
000
"$t" eq 1 or "$t" eq "s"
l!l&&r!l&&!r
000
MC/DC0%0/3
"$t" eq 1 or "$t" eq "s" or "$t" eq "square"
"$t" eq 1 "$t" eq "s" "$t" eq "square"
Truth table0%0/4
A or B or C
A= "$t" eq 1B= "$t" eq "s"C= "$t" eq "square"
ABCresult
1XX1
01X1
0011
0000
1473 0 $self->{'ds'} = 1;
1474 }
1475 0 ▶ if(("$t" eq "2") || ("$t" eq "d") || ("$t" eq "diamond")) {
Branch: 1 branch
BranchTrueFalseTotal
if ("$t" eq 2 or "$t" eq "d" or "$t" eq "diamond") 0 0 0
Condition0%0/6
"$t" eq 2 or "$t" eq "d" or "$t" eq "diamond"
l!l&&r!l&&!r
000
"$t" eq 2 or "$t" eq "d"
l!l&&r!l&&!r
000
MC/DC0%0/3
"$t" eq 2 or "$t" eq "d" or "$t" eq "diamond"
"$t" eq 2 "$t" eq "d" "$t" eq "diamond"
Truth table0%0/4
A or B or C
A= "$t" eq 2B= "$t" eq "d"C= "$t" eq "diamond"
ABCresult
1XX1
01X1
0011
0000
1476 0 $self->{'ds'} = 2;
1477 }
1478 0 ▶ if(("$t" eq "3") || ("$t" eq "t") || ("$t" eq "triangle")) {
Branch: 1 branch
BranchTrueFalseTotal
if ("$t" eq 3 or "$t" eq "t" or "$t" eq "triangle") 0 0 0
Condition0%0/6
"$t" eq 3 or "$t" eq "t" or "$t" eq "triangle"
l!l&&r!l&&!r
000
"$t" eq 3 or "$t" eq "t"
l!l&&r!l&&!r
000
MC/DC0%0/3
"$t" eq 3 or "$t" eq "t" or "$t" eq "triangle"
"$t" eq 3 "$t" eq "t" "$t" eq "triangle"
Truth table0%0/4
A or B or C
A= "$t" eq 3B= "$t" eq "t"C= "$t" eq "triangle"
ABCresult
1XX1
01X1
0011
0000
1479 0 $self->{'ds'} = 3;
1480 }
1481 0 ▶ if(("$t" eq "4") || ("$t" eq "cr") || ("$t" eq "crosshair")) {
Branch: 1 branch
BranchTrueFalseTotal
if ("$t" eq 4 or "$t" eq "cr" or "$t" eq "crosshair") 0 0 0
Condition0%0/6
"$t" eq 4 or "$t" eq "cr" or "$t" eq "crosshair"
l!l&&r!l&&!r
000
"$t" eq 4 or "$t" eq "cr"
l!l&&r!l&&!r
000
MC/DC0%0/3
"$t" eq 4 or "$t" eq "cr" or "$t" eq "crosshair"
"$t" eq 4 "$t" eq "cr" "$t" eq "crosshair"
Truth table0%0/4
A or B or C
A= "$t" eq 4B= "$t" eq "cr"C= "$t" eq "crosshair"
ABCresult
1XX1
01X1
0011
0000
1482 0 $self->{'ds'} = 4;
1483 }
1484 0 ▶ if(("$t" eq "5") || ("$t" eq "p") || ("$t" eq "pentagon")) {
Branch: 1 branch
BranchTrueFalseTotal
if ("$t" eq 5 or "$t" eq "p" or "$t" eq "pentagon") 0 0 0
Condition0%0/6
"$t" eq 5 or "$t" eq "p" or "$t" eq "pentagon"
l!l&&r!l&&!r
000
"$t" eq 5 or "$t" eq "p"
l!l&&r!l&&!r
000
MC/DC0%0/3
"$t" eq 5 or "$t" eq "p" or "$t" eq "pentagon"
"$t" eq 5 "$t" eq "p" "$t" eq "pentagon"
Truth table0%0/4
A or B or C
A= "$t" eq 5B= "$t" eq "p"C= "$t" eq "pentagon"
ABCresult
1XX1
01X1
0011
0000
1485 0 $self->{'ds'} = 5;
1486 }
1487 0 ▶ if($#_ >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ >= 0) 0 0 0
1488 0 $self->{'dsz'} = shift;
1489 }
1490 }
1491 }
1492 0 return $self;
1493 }
1494  
1495  
1496  
1497 sub debug
1498 0 ▶{
Subroutine debug: not called CC=5 SCAR=34.0
Pod undocumented
1499 0 my $self = undef;
1500 0 ▶ if($#_ >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ >= 0) 0 0 0
1501 0 $self = shift;
1502 0 my $msg = ""; my $i = 0;
1503 0 ▶ while($#_ > -1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ > -1) 0 0 0
1504 0 ▶ if($i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i) { } 0 0 0
1505 0 $msg = "$msg " . shift;
1506 } else {
1507 0 $msg = shift;
1508 }
1509 0 $i++;
1510 }
1511 0 ▶ if($self->{'debug'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"debug"}) 0 0 0
1512 0 print "DEBUG $msg\n";
1513 }
1514 }
1515 0 return $self;
1516 }
1517  
1518  
1519  
1520 sub set_intervals
1521 0 ▶{
Subroutine set_intervals: not called CC=3 SCAR=24.8
Pod undocumented
1522 0 my $self = undef;
1523 0 ▶ if($#_ < 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ < 1) { } 0 0 0
1524 0 croak "Usage: \$plot->set_intervals(number)";
1525 } else {
1526 0 $self = shift;
1527 0 my $n = shift;
1528 0 ▶ if($n < 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n < 1) { } 0 0 0
1529 0 croak "ERROR: At least one interval is needed!";
1530 } else {
1531 0 $self->{'i'} = $n;
1532 }
1533 }
1534 0 return $self;
1535 }
1536  
1537  
1538  
1539 sub set_color
1540 0 ▶{
Subroutine set_color: not called CC=2 SCAR=17.9
Pod undocumented
1541 0 my $self = undef;
1542 0 ▶ if($#_ < 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ < 1) { } 0 0 0
1543 0 croak "Usage: \$plot->set_color(color)";
1544 } else {
1545 0 $self = shift; $self->{'color'} = shift;
1546 }
1547 0 return $self;
1548 }
1549  
1550  
1551  
1552 sub set_xsplines_segments
1553 0 ▶{
Subroutine set_xsplines_segments: not called CC=2 SCAR=17.9
Pod undocumented
1554 0 my $self = undef;
1555 0 ▶ if($#_ >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ >= 1) { } 0 0 0
1556 0 $self = shift; $self->{'xspline'} = shift;
1557 } else {
1558 0 croak "Usage: \$plot->set_xsplines_segments(num)";
1559 }
1560 0 return $self;
1561 }
1562  
1563  
1564  
1565 sub set_range
1566 0 ▶{
Subroutine set_range: not called CC=2 SCAR=17.9
Pod undocumented
1567 0 my $self = undef;
1568 0 ▶ if($#_ >= 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ >= 2) { } 0 0 0
1569 0 $self = shift; my $min = shift; my $max = shift;
1570 0 $self->{'r'} = [ $min, $max ];
1571 } else {
1572 0 croak "Usage: \$plot->set_range(min, max)";
1573 }
1574 0 return $self;
1575 }
1576  
1577  
1578 1 1;
1579  
1580 __END__
« Diagram2D.pm ↑ Summary Diagram2D/Axis.pm »