line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# XFig Drawing Library |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# Copyright (c) 2017 D Scott Guthridge |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This program is free software: you can redistribute it and/or modify it under |
7
|
|
|
|
|
|
|
# the terms of the Artistic License as published by the Perl Foundation, either |
8
|
|
|
|
|
|
|
# version 2.0 of the License, or (at your option) any later version. |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT |
11
|
|
|
|
|
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
12
|
|
|
|
|
|
|
# FOR A PARTICULAR PURPOSE. See the Artistic License for more details. |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# You should have received a copy of the Artistic License along with this |
15
|
|
|
|
|
|
|
# program. If not, see . |
16
|
|
|
|
|
|
|
# |
17
|
|
|
|
|
|
|
package Graphics::Fig::Arc; |
18
|
|
|
|
|
|
|
our $VERSION = 'v1.0.5'; |
19
|
|
|
|
|
|
|
|
20
|
12
|
|
|
12
|
|
78
|
use strict; |
|
12
|
|
|
|
|
24
|
|
|
12
|
|
|
|
|
399
|
|
21
|
12
|
|
|
12
|
|
57
|
use warnings; |
|
12
|
|
|
|
|
17
|
|
|
12
|
|
|
|
|
331
|
|
22
|
12
|
|
|
12
|
|
758
|
use utf8; |
|
12
|
|
|
|
|
33
|
|
|
12
|
|
|
|
|
78
|
|
23
|
12
|
|
|
12
|
|
234
|
use Carp; |
|
12
|
|
|
|
|
18
|
|
|
12
|
|
|
|
|
685
|
|
24
|
12
|
|
|
12
|
|
62
|
use Math::Trig; |
|
12
|
|
|
|
|
20
|
|
|
12
|
|
|
|
|
1808
|
|
25
|
12
|
|
|
12
|
|
84
|
use Graphics::Fig::Color; |
|
12
|
|
|
|
|
22
|
|
|
12
|
|
|
|
|
258
|
|
26
|
12
|
|
|
12
|
|
5921
|
use Graphics::Fig::Ellipse; |
|
12
|
|
|
|
|
29
|
|
|
12
|
|
|
|
|
404
|
|
27
|
12
|
|
|
12
|
|
89
|
use Graphics::Fig::Matrix; |
|
12
|
|
|
|
|
22
|
|
|
12
|
|
|
|
|
208
|
|
28
|
12
|
|
|
12
|
|
53
|
use Graphics::Fig::Parameters; |
|
12
|
|
|
|
|
19
|
|
|
12
|
|
|
|
|
169
|
|
29
|
12
|
|
|
12
|
|
70
|
use Graphics::Fig::Arc; |
|
12
|
|
|
|
|
27
|
|
|
12
|
|
|
|
|
51596
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# |
32
|
|
|
|
|
|
|
# RE_INT: regular expression matching an integer |
33
|
|
|
|
|
|
|
# |
34
|
|
|
|
|
|
|
my $RE_INT = '(?:(?:[-+]?)(?:[0123456789]+))'; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# |
37
|
|
|
|
|
|
|
# Graphics::Fig::Arc::convertSubtype |
38
|
|
|
|
|
|
|
# $fig: Fig instance |
39
|
|
|
|
|
|
|
# $prefix: error message prefix |
40
|
|
|
|
|
|
|
# $value: direction parameter |
41
|
|
|
|
|
|
|
# $context: parameter context |
42
|
|
|
|
|
|
|
# |
43
|
|
|
|
|
|
|
sub convertSubtype { |
44
|
3
|
|
|
3
|
0
|
8
|
my $fig = shift; |
45
|
3
|
|
|
|
|
5
|
my $prefix = shift; |
46
|
3
|
|
|
|
|
5
|
my $value = shift; |
47
|
3
|
|
|
|
|
6
|
my $context = shift; |
48
|
3
|
|
|
|
|
5
|
my $result; |
49
|
|
|
|
|
|
|
my $temp; |
50
|
|
|
|
|
|
|
|
51
|
3
|
|
|
|
|
8
|
$value =~ y/[A-Z]/[a-z]/; |
52
|
3
|
50
|
|
|
|
11
|
if ($value eq "open") { |
53
|
0
|
|
|
|
|
0
|
return 1; |
54
|
|
|
|
|
|
|
} |
55
|
3
|
50
|
66
|
|
|
28
|
if ($value eq "pie" || $value eq "pie-wedge" || $value eq "closed") { |
|
|
|
66
|
|
|
|
|
56
|
3
|
|
|
|
|
10
|
return 2; |
57
|
|
|
|
|
|
|
} |
58
|
0
|
0
|
|
|
|
0
|
if (!($value =~ s/^\s*($RE_INT)//)) { |
59
|
0
|
|
|
|
|
0
|
croak("${prefix}: ${value}: error: expected open or pie"); |
60
|
|
|
|
|
|
|
} |
61
|
0
|
0
|
0
|
|
|
0
|
if ($value != 1 && $value != 2) { |
62
|
0
|
|
|
|
|
0
|
croak("${prefix}: ${value}: error: expected 1 or 2"); |
63
|
|
|
|
|
|
|
} |
64
|
0
|
|
|
|
|
0
|
return $value; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# |
68
|
|
|
|
|
|
|
# Graphics::Fig::Arc::convertDirection |
69
|
|
|
|
|
|
|
# $fig: Fig instance |
70
|
|
|
|
|
|
|
# $prefix: error message prefix |
71
|
|
|
|
|
|
|
# $value: direction parameter |
72
|
|
|
|
|
|
|
# $context: parameter context |
73
|
|
|
|
|
|
|
# |
74
|
|
|
|
|
|
|
sub convertDirection { |
75
|
5
|
|
|
5
|
0
|
11
|
my $fig = shift; |
76
|
5
|
|
|
|
|
9
|
my $prefix = shift; |
77
|
5
|
|
|
|
|
9
|
my $value = shift; |
78
|
5
|
|
|
|
|
6
|
my $context = shift; |
79
|
5
|
|
|
|
|
11
|
my $result; |
80
|
|
|
|
|
|
|
my $temp; |
81
|
|
|
|
|
|
|
|
82
|
5
|
|
|
|
|
13
|
$value =~ y/[A-Z]/[a-z]/; |
83
|
5
|
100
|
66
|
|
|
28
|
if ($value eq "clockwise" || $value eq "cw") { |
84
|
2
|
|
|
|
|
6
|
return 0; |
85
|
|
|
|
|
|
|
} |
86
|
3
|
50
|
33
|
|
|
15
|
if ($value eq "counterclockwise" || $value eq "ccw") { |
87
|
3
|
|
|
|
|
9
|
return 1; |
88
|
|
|
|
|
|
|
} |
89
|
0
|
0
|
|
|
|
0
|
if (!($value =~ s/^\s*($RE_INT)//)) { |
90
|
0
|
|
|
|
|
0
|
croak("${prefix}: ${value}: error: expected clockwise or " . |
91
|
|
|
|
|
|
|
"counterclockwise"); |
92
|
|
|
|
|
|
|
} |
93
|
0
|
0
|
0
|
|
|
0
|
if ($value != 0 && $value != 1) { |
94
|
0
|
|
|
|
|
0
|
croak("${prefix}: ${value}: error: expected 0 or 1"); |
95
|
|
|
|
|
|
|
} |
96
|
0
|
|
|
|
|
0
|
return $value; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# |
100
|
|
|
|
|
|
|
# Arc Parameters |
101
|
|
|
|
|
|
|
# |
102
|
|
|
|
|
|
|
my %ArcParameterTemplate = ( |
103
|
|
|
|
|
|
|
positional => { |
104
|
|
|
|
|
|
|
"." => [ "r" ], |
105
|
|
|
|
|
|
|
".." => [ "r", "angle" ], |
106
|
|
|
|
|
|
|
"@" => [ "points" ], |
107
|
|
|
|
|
|
|
}, |
108
|
|
|
|
|
|
|
named => [ |
109
|
|
|
|
|
|
|
\%Graphics::Fig::Parameters::UnitsParameter, # must be first |
110
|
|
|
|
|
|
|
\%Graphics::Fig::Parameters::PositionParameter, # must be second |
111
|
|
|
|
|
|
|
@Graphics::Fig::Parameters::ArrowParameters, |
112
|
|
|
|
|
|
|
\%Graphics::Fig::Parameters::CapStyleParameter, |
113
|
|
|
|
|
|
|
\%Graphics::Fig::Parameters::CenterParameter, |
114
|
|
|
|
|
|
|
\%Graphics::Fig::Parameters::ColorParameter, |
115
|
|
|
|
|
|
|
\%Graphics::Fig::Parameters::DepthParameter, |
116
|
|
|
|
|
|
|
@Graphics::Fig::Parameters::FillParameters, |
117
|
|
|
|
|
|
|
@Graphics::Fig::Parameters::LineParameters, |
118
|
|
|
|
|
|
|
\%Graphics::Fig::Parameters::PointsParameter, |
119
|
|
|
|
|
|
|
\%Graphics::Fig::Parameters::RotationParameter, |
120
|
|
|
|
|
|
|
{ |
121
|
|
|
|
|
|
|
name => "subtype", |
122
|
|
|
|
|
|
|
convert => \&convertSubtype, |
123
|
|
|
|
|
|
|
default => 1 |
124
|
|
|
|
|
|
|
}, |
125
|
|
|
|
|
|
|
{ |
126
|
|
|
|
|
|
|
name => "d", |
127
|
|
|
|
|
|
|
aliases => [ "diameter" ], |
128
|
|
|
|
|
|
|
convert => \&Graphics::Fig::Parameters::convertLength, |
129
|
|
|
|
|
|
|
}, |
130
|
|
|
|
|
|
|
{ |
131
|
|
|
|
|
|
|
name => "r", |
132
|
|
|
|
|
|
|
aliases => [ "radius" ], |
133
|
|
|
|
|
|
|
convert => \&Graphics::Fig::Parameters::convertLength, |
134
|
|
|
|
|
|
|
}, |
135
|
|
|
|
|
|
|
{ |
136
|
|
|
|
|
|
|
name => "direction", |
137
|
|
|
|
|
|
|
convert => \&convertDirection, |
138
|
|
|
|
|
|
|
}, |
139
|
|
|
|
|
|
|
{ |
140
|
|
|
|
|
|
|
name => "controlAngle", |
141
|
|
|
|
|
|
|
convert => \&Graphics::Fig::Parameters::convertAngle, |
142
|
|
|
|
|
|
|
}, |
143
|
|
|
|
|
|
|
{ |
144
|
|
|
|
|
|
|
name => "angle", |
145
|
|
|
|
|
|
|
aliases => [ "Θ" ], |
146
|
|
|
|
|
|
|
convert => \&Graphics::Fig::Parameters::convertAngle, |
147
|
|
|
|
|
|
|
}, |
148
|
|
|
|
|
|
|
], |
149
|
|
|
|
|
|
|
); |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
# |
152
|
|
|
|
|
|
|
# Arcto Parameters |
153
|
|
|
|
|
|
|
# |
154
|
|
|
|
|
|
|
my %ArctoParameterTemplate = ( |
155
|
|
|
|
|
|
|
positional => { |
156
|
|
|
|
|
|
|
".." => [ "distance", "heading" ], |
157
|
|
|
|
|
|
|
"..." => [ "distance", "heading", "angle" ], |
158
|
|
|
|
|
|
|
"@" => [ "points" ], |
159
|
|
|
|
|
|
|
}, |
160
|
|
|
|
|
|
|
named => [ |
161
|
|
|
|
|
|
|
\%Graphics::Fig::Parameters::UnitsParameter, # must be first |
162
|
|
|
|
|
|
|
\%Graphics::Fig::Parameters::PositionParameter, # must be second |
163
|
|
|
|
|
|
|
@Graphics::Fig::Parameters::ArrowParameters, |
164
|
|
|
|
|
|
|
\%Graphics::Fig::Parameters::CapStyleParameter, |
165
|
|
|
|
|
|
|
\%Graphics::Fig::Parameters::CenterParameter, |
166
|
|
|
|
|
|
|
\%Graphics::Fig::Parameters::ColorParameter, |
167
|
|
|
|
|
|
|
\%Graphics::Fig::Parameters::DepthParameter, |
168
|
|
|
|
|
|
|
@Graphics::Fig::Parameters::FillParameters, |
169
|
|
|
|
|
|
|
@Graphics::Fig::Parameters::LineParameters, |
170
|
|
|
|
|
|
|
\%Graphics::Fig::Parameters::PointsParameter, |
171
|
|
|
|
|
|
|
{ |
172
|
|
|
|
|
|
|
name => "distance", |
173
|
|
|
|
|
|
|
convert => \&Graphics::Fig::Parameters::convertLength, |
174
|
|
|
|
|
|
|
}, |
175
|
|
|
|
|
|
|
{ |
176
|
|
|
|
|
|
|
name => "heading", |
177
|
|
|
|
|
|
|
convert => \&Graphics::Fig::Parameters::convertAngle, |
178
|
|
|
|
|
|
|
}, |
179
|
|
|
|
|
|
|
{ |
180
|
|
|
|
|
|
|
name => "subtype", |
181
|
|
|
|
|
|
|
convert => \&convertSubtype, |
182
|
|
|
|
|
|
|
default => 1 |
183
|
|
|
|
|
|
|
}, |
184
|
|
|
|
|
|
|
{ |
185
|
|
|
|
|
|
|
name => "direction", |
186
|
|
|
|
|
|
|
convert => \&convertDirection, |
187
|
|
|
|
|
|
|
}, |
188
|
|
|
|
|
|
|
{ |
189
|
|
|
|
|
|
|
name => "controlAngle", |
190
|
|
|
|
|
|
|
convert => \&Graphics::Fig::Parameters::convertAngle, |
191
|
|
|
|
|
|
|
}, |
192
|
|
|
|
|
|
|
{ |
193
|
|
|
|
|
|
|
name => "angle", |
194
|
|
|
|
|
|
|
aliases => [ "Θ", ], |
195
|
|
|
|
|
|
|
convert => \&Graphics::Fig::Parameters::convertAngle, |
196
|
|
|
|
|
|
|
}, |
197
|
|
|
|
|
|
|
], |
198
|
|
|
|
|
|
|
); |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
# |
201
|
|
|
|
|
|
|
# Graphics::Fig::Arg::normalizeAngle: normalize angle to [-2 pi .. 2 pi ] |
202
|
|
|
|
|
|
|
# with sign consistent with direction |
203
|
|
|
|
|
|
|
# $angle: angle |
204
|
|
|
|
|
|
|
# $direction: 1:CCW 0:CW |
205
|
|
|
|
|
|
|
# |
206
|
|
|
|
|
|
|
sub normalizeAngle { |
207
|
24
|
|
|
24
|
0
|
39
|
my $angle = shift; |
208
|
24
|
|
|
|
|
36
|
my $direction = shift; |
209
|
|
|
|
|
|
|
|
210
|
24
|
100
|
|
|
|
59
|
if (abs($angle) > pi) { |
211
|
2
|
|
|
|
|
31
|
$angle = atan2(sin($angle), cos($angle)); |
212
|
|
|
|
|
|
|
} |
213
|
24
|
50
|
33
|
|
|
93
|
die "arc: internal error 1" unless ($angle >= - pi && $angle <= pi); |
214
|
24
|
100
|
100
|
|
|
127
|
if ($direction && $angle < 0) { |
|
|
100
|
100
|
|
|
|
|
215
|
1
|
|
|
|
|
5
|
$angle += 2 * pi; |
216
|
|
|
|
|
|
|
} elsif (!$direction && $angle > 0) { |
217
|
3
|
|
|
|
|
57
|
$angle -= 2 * pi; |
218
|
|
|
|
|
|
|
} |
219
|
24
|
|
|
|
|
49
|
return $angle; |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
# |
223
|
|
|
|
|
|
|
# Graphics::Fig::Arc::calcAngleParameters: find angles from parameters |
224
|
|
|
|
|
|
|
# $parameters: reference to parameter hash |
225
|
|
|
|
|
|
|
# |
226
|
|
|
|
|
|
|
# The returned angle is in the range [-2 pi .. 2 pi] given the width |
227
|
|
|
|
|
|
|
# of the arc, where positive values indicate a counterclockwise arc and |
228
|
|
|
|
|
|
|
# negative values indicate a clockwise arc. The returned controlAngle |
229
|
|
|
|
|
|
|
# is lower in magnitude and follows the sign of angle. |
230
|
|
|
|
|
|
|
# |
231
|
|
|
|
|
|
|
# Return: |
232
|
|
|
|
|
|
|
# ( angle, controlAngle ) |
233
|
|
|
|
|
|
|
# |
234
|
|
|
|
|
|
|
sub calcAngleParameters { |
235
|
20
|
|
|
20
|
0
|
37
|
my $parameters = shift; |
236
|
20
|
|
|
|
|
27
|
my $angle = ${$parameters}{"angle"}; |
|
20
|
|
|
|
|
45
|
|
237
|
20
|
|
|
|
|
42
|
my $controlAngle = ${$parameters}{"controlAngle"}; |
|
20
|
|
|
|
|
38
|
|
238
|
20
|
|
|
|
|
28
|
my $direction = ${$parameters}{"direction"}; |
|
20
|
|
|
|
|
31
|
|
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
# |
241
|
|
|
|
|
|
|
# If the direction wasn't given, take it from the sign of angle. |
242
|
|
|
|
|
|
|
# If angle wasn't given, take it from the sign of controlAngle. |
243
|
|
|
|
|
|
|
# If controlAngle wasn't given, default to counterclockwise. |
244
|
|
|
|
|
|
|
# |
245
|
20
|
100
|
|
|
|
43
|
if (!defined($direction)) { |
246
|
15
|
100
|
|
|
|
33
|
if (defined($angle)) { |
|
|
100
|
|
|
|
|
|
247
|
8
|
|
|
|
|
18
|
$direction = $angle >= 0; |
248
|
|
|
|
|
|
|
} elsif (defined($controlAngle)) { |
249
|
2
|
|
|
|
|
7
|
$direction = $controlAngle >= 0; |
250
|
|
|
|
|
|
|
} else { |
251
|
5
|
|
|
|
|
9
|
$direction = 1; |
252
|
|
|
|
|
|
|
} |
253
|
|
|
|
|
|
|
} |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
# |
256
|
|
|
|
|
|
|
# Normalize angle. If not given, default it to pi/2 or -pi/2 |
257
|
|
|
|
|
|
|
# depending on direction. |
258
|
|
|
|
|
|
|
# |
259
|
20
|
100
|
|
|
|
41
|
if (defined($angle)) { |
260
|
9
|
|
|
|
|
20
|
$angle = &normalizeAngle($angle, $direction); |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
} else { |
263
|
11
|
100
|
|
|
|
23
|
if ($direction) { |
264
|
9
|
|
|
|
|
14
|
$angle = pi / 2; |
265
|
|
|
|
|
|
|
} else { |
266
|
2
|
|
|
|
|
5
|
$angle = - pi / 2; |
267
|
|
|
|
|
|
|
} |
268
|
|
|
|
|
|
|
} |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
# |
271
|
|
|
|
|
|
|
# Normalize controlAngle and test that it's within the arc. If not |
272
|
|
|
|
|
|
|
# given, default it to $angle / 2. |
273
|
|
|
|
|
|
|
# |
274
|
20
|
100
|
|
|
|
44
|
if (defined($controlAngle)) { |
275
|
3
|
|
|
|
|
14
|
$controlAngle = &normalizeAngle($controlAngle, $direction); |
276
|
3
|
50
|
|
|
|
21
|
if (abs($controlAngle) >= abs($angle)) { |
277
|
0
|
|
|
|
|
0
|
croak("arc: error: controlAngle is outside of arc"); |
278
|
|
|
|
|
|
|
} |
279
|
|
|
|
|
|
|
} else { |
280
|
17
|
|
|
|
|
27
|
$controlAngle = $angle / 2; |
281
|
|
|
|
|
|
|
} |
282
|
|
|
|
|
|
|
|
283
|
20
|
50
|
|
|
|
50
|
die "arc: internal error 2" if $angle * $controlAngle < 0; |
284
|
20
|
50
|
|
|
|
47
|
die "arc: internal error 3" if abs($controlAngle) > abs($angle); |
285
|
20
|
50
|
|
|
|
43
|
die "arc: internal error 4" if $controlAngle * $angle < 0; |
286
|
|
|
|
|
|
|
|
287
|
20
|
|
|
|
|
69
|
return ( $angle, $controlAngle ); |
288
|
|
|
|
|
|
|
} |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
# |
291
|
|
|
|
|
|
|
# Graphics::Fig::Arc::calcAnglesFromPoints: find angles from three points |
292
|
|
|
|
|
|
|
# $points: [ [ x1, y1 ], [ x2, y2 ], [ x3, y3 ] ] |
293
|
|
|
|
|
|
|
# |
294
|
|
|
|
|
|
|
# The returned angle is in the range [-2 pi .. 2 pi] given the width |
295
|
|
|
|
|
|
|
# of the arc, where positive values indicate a counterclockwise arc and |
296
|
|
|
|
|
|
|
# negative values indicate a clockwise arc. The returned controlAngle |
297
|
|
|
|
|
|
|
# is lower in magnitude and follows the sign of angle. |
298
|
|
|
|
|
|
|
# |
299
|
|
|
|
|
|
|
# Return: |
300
|
|
|
|
|
|
|
# ( angle, controlAngle ) |
301
|
|
|
|
|
|
|
# |
302
|
|
|
|
|
|
|
sub calcAnglesFromPoints { |
303
|
6
|
|
|
6
|
0
|
11
|
my $points = shift; |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
# |
306
|
|
|
|
|
|
|
# Let A = 1. Solve for D, E and F: |
307
|
|
|
|
|
|
|
# D x1 + E y1 + F == -(x1^2 + y1^2) |
308
|
|
|
|
|
|
|
# D x2 + E y2 + F == -(x2^2 + y2^2) |
309
|
|
|
|
|
|
|
# D x3 + E y3 + F == -(x3^2 + y3^2) |
310
|
|
|
|
|
|
|
# |
311
|
6
|
|
|
|
|
11
|
my $x1 = ${$points}[0][0]; |
|
6
|
|
|
|
|
14
|
|
312
|
6
|
|
|
|
|
11
|
my $y1 = ${$points}[0][1]; |
|
6
|
|
|
|
|
11
|
|
313
|
6
|
|
|
|
|
10
|
my $x2 = ${$points}[1][0]; |
|
6
|
|
|
|
|
13
|
|
314
|
6
|
|
|
|
|
8
|
my $y2 = ${$points}[1][1]; |
|
6
|
|
|
|
|
11
|
|
315
|
6
|
|
|
|
|
7
|
my $x3 = ${$points}[2][0]; |
|
6
|
|
|
|
|
10
|
|
316
|
6
|
|
|
|
|
11
|
my $y3 = ${$points}[2][1]; |
|
6
|
|
|
|
|
11
|
|
317
|
6
|
|
|
|
|
49
|
my @M = ( |
318
|
|
|
|
|
|
|
[ $x1, $y1, 1, -($x1*$x1 + $y1*$y1) ], |
319
|
|
|
|
|
|
|
[ $x2, $y2, 1, -($x2*$x2 + $y2*$y2) ], |
320
|
|
|
|
|
|
|
[ $x3, $y3, 1, -($x3*$x3 + $y3*$y3) ], |
321
|
|
|
|
|
|
|
); |
322
|
6
|
|
|
|
|
27
|
my $d = Graphics::Fig::Matrix::reduce(\@M); |
323
|
6
|
50
|
|
|
|
27
|
if (abs($d) < Graphics::Fig::Matrix::EPS) { |
324
|
0
|
|
|
|
|
0
|
croak("arc: error: singular matrix"); |
325
|
|
|
|
|
|
|
} |
326
|
6
|
|
|
|
|
15
|
my $D = $M[0][3]; |
327
|
6
|
|
|
|
|
9
|
my $E = $M[1][3]; |
328
|
6
|
|
|
|
|
10
|
my $F = $M[2][3]; |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
# |
331
|
|
|
|
|
|
|
# Find the arc direction by finding the sign of the the z component |
332
|
|
|
|
|
|
|
# of the cross product of point2-point1 and point3-point1. |
333
|
|
|
|
|
|
|
# |
334
|
6
|
|
|
|
|
22
|
my $z = $x1 * ($y2 - $y3) + $x2 * ($y3 - $y1) + $x3 * ($y1 - $y2); |
335
|
6
|
|
|
|
|
13
|
my $direction = ($z < 0); |
336
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
# |
338
|
|
|
|
|
|
|
# Find center and radius and compute angles. |
339
|
|
|
|
|
|
|
# |
340
|
6
|
|
|
|
|
12
|
my ($x, $y); |
341
|
6
|
|
|
|
|
28
|
my ($r, $b, $xc, $yc, $dummy_rotation) = |
342
|
|
|
|
|
|
|
Graphics::Fig::Ellipse::generalToCanonical(1, 0, 1, $D, $E, $F); |
343
|
6
|
50
|
|
|
|
21
|
die "arc: internal error 6: $r != $b" unless $r == $b; |
344
|
6
|
|
|
|
|
15
|
my $c = ($x1 - $xc) / $r; |
345
|
6
|
|
|
|
|
10
|
my $s = -($y1 - $yc) / $r; |
346
|
6
|
|
|
|
|
14
|
$x = $c * ($x2 - $xc) - $s * ($y2 - $yc); |
347
|
6
|
|
|
|
|
13
|
$y = $s * ($x2 - $xc) + $c * ($y2 - $yc); |
348
|
6
|
|
|
|
|
27
|
my $controlAngle = &normalizeAngle(atan2(-$y, $x), $direction); |
349
|
6
|
|
|
|
|
17
|
$x = $c * ($x3 - $xc) - $s * ($y3 - $yc); |
350
|
6
|
|
|
|
|
14
|
$y = $s * ($x3 - $xc) + $c * ($y3 - $yc); |
351
|
6
|
|
|
|
|
15
|
my $angle = &normalizeAngle(atan2(-$y, $x), $direction);; |
352
|
|
|
|
|
|
|
|
353
|
6
|
50
|
|
|
|
24
|
die "arc: internal error 7" if abs($controlAngle) > abs($angle); |
354
|
6
|
50
|
|
|
|
17
|
die "arc: internal error 8" if $controlAngle * $angle < 0; |
355
|
|
|
|
|
|
|
|
356
|
6
|
|
|
|
|
27
|
return ( $angle, $controlAngle ); |
357
|
|
|
|
|
|
|
} |
358
|
|
|
|
|
|
|
|
359
|
|
|
|
|
|
|
# |
360
|
|
|
|
|
|
|
# Graphics::Fig::Arc::findPoint2: return the center and point2 |
361
|
|
|
|
|
|
|
# $self: object |
362
|
|
|
|
|
|
|
# |
363
|
|
|
|
|
|
|
# Return: ([ xc, yc ], [ x2, y2 ]) |
364
|
|
|
|
|
|
|
# |
365
|
|
|
|
|
|
|
sub findPoint2 { |
366
|
26
|
|
|
26
|
0
|
34
|
my $self = shift; |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
# |
369
|
|
|
|
|
|
|
# Get points and angles. |
370
|
|
|
|
|
|
|
# |
371
|
26
|
|
|
|
|
31
|
my $point1 = ${$self}{"point1"}; |
|
26
|
|
|
|
|
47
|
|
372
|
26
|
|
|
|
|
33
|
my $point3 = ${$self}{"point3"}; |
|
26
|
|
|
|
|
43
|
|
373
|
26
|
|
|
|
|
34
|
my $angle = ${$self}{"angle"}; |
|
26
|
|
|
|
|
36
|
|
374
|
26
|
|
|
|
|
35
|
my $controlAngle = ${$self}{"controlAngle"}; |
|
26
|
|
|
|
|
48
|
|
375
|
26
|
|
|
|
|
35
|
my $x1 = ${$point1}[0]; |
|
26
|
|
|
|
|
45
|
|
376
|
26
|
|
|
|
|
38
|
my $y1 = ${$point1}[1]; |
|
26
|
|
|
|
|
46
|
|
377
|
26
|
|
|
|
|
35
|
my $x3 = ${$point3}[0]; |
|
26
|
|
|
|
|
94
|
|
378
|
26
|
|
|
|
|
36
|
my $y3 = ${$point3}[1]; |
|
26
|
|
|
|
|
43
|
|
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
# |
381
|
|
|
|
|
|
|
# Find the center. |
382
|
|
|
|
|
|
|
# |
383
|
26
|
|
|
|
|
89
|
my $half_cot = cot($angle / 2) / 2; |
384
|
26
|
|
|
|
|
500
|
my $xc = $x1 + ($x3 - $x1) / 2 + ($y3 - $y1) * $half_cot; |
385
|
26
|
|
|
|
|
54
|
my $yc = $y1 + ($y3 - $y1) / 2 - ($x3 - $x1) * $half_cot; |
386
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
# |
388
|
|
|
|
|
|
|
# Find point 2. |
389
|
|
|
|
|
|
|
# |
390
|
26
|
|
|
|
|
44
|
my $c = cos($controlAngle); |
391
|
26
|
|
|
|
|
47
|
my $s = sin($controlAngle); |
392
|
26
|
|
|
|
|
50
|
my $x = $x1 - $xc; |
393
|
26
|
|
|
|
|
36
|
my $y = $y1 - $yc; |
394
|
26
|
|
|
|
|
56
|
my $x2 = $xc + $c * $x + $s * $y; |
395
|
26
|
|
|
|
|
45
|
my $y2 = $yc + -$s * $x + $c * $y; |
396
|
|
|
|
|
|
|
|
397
|
26
|
|
|
|
|
94
|
return ([ $xc, $yc ], [ $x2, $y2 ]); |
398
|
|
|
|
|
|
|
} |
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
# |
401
|
|
|
|
|
|
|
# Graphics::Fig::Arc::arc constructor |
402
|
|
|
|
|
|
|
# $proto: prototype |
403
|
|
|
|
|
|
|
# $fig: parent object |
404
|
|
|
|
|
|
|
# @parameters: arc parameters |
405
|
|
|
|
|
|
|
# |
406
|
|
|
|
|
|
|
sub arc { |
407
|
11
|
|
|
11
|
0
|
22
|
my $proto = shift; |
408
|
11
|
|
|
|
|
14
|
my $fig = shift; |
409
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
# |
411
|
|
|
|
|
|
|
# Parse parameters. |
412
|
|
|
|
|
|
|
# |
413
|
11
|
|
|
|
|
81
|
my %parameters; |
414
|
11
|
|
|
|
|
48
|
my $stack = ${$fig}{"stack"}; |
|
11
|
|
|
|
|
23
|
|
415
|
11
|
|
|
|
|
17
|
my $tos = ${$stack}[$#{$stack}]; |
|
11
|
|
|
|
|
18
|
|
|
11
|
|
|
|
|
18
|
|
416
|
11
|
|
|
|
|
18
|
eval { |
417
|
|
|
|
|
|
|
Graphics::Fig::Parameters::parse($fig, "arc", |
418
|
|
|
|
|
|
|
\%ArcParameterTemplate, |
419
|
11
|
|
|
|
|
22
|
${$tos}{"options"}, \%parameters, @_); |
|
11
|
|
|
|
|
32
|
|
420
|
|
|
|
|
|
|
}; |
421
|
11
|
50
|
|
|
|
28
|
if ($@) { |
422
|
0
|
|
|
|
|
0
|
$@ =~ s/ at [^\s]* line \d+\.\n//; |
423
|
0
|
|
|
|
|
0
|
croak("$@"); |
424
|
|
|
|
|
|
|
} |
425
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
# |
427
|
|
|
|
|
|
|
# Construct the object. Undefined parameters are set below. |
428
|
|
|
|
|
|
|
# |
429
|
|
|
|
|
|
|
my $self = { |
430
|
|
|
|
|
|
|
subtype => $parameters{"subtype"}, |
431
|
|
|
|
|
|
|
lineStyle => $parameters{"lineStyle"}, |
432
|
|
|
|
|
|
|
lineThickness => $parameters{"lineThickness"}, |
433
|
|
|
|
|
|
|
penColor => $parameters{"penColor"}, |
434
|
|
|
|
|
|
|
fillColor => $parameters{"fillColor"}, |
435
|
|
|
|
|
|
|
depth => $parameters{"depth"}, |
436
|
|
|
|
|
|
|
areaFill => $parameters{"areaFill"}, |
437
|
|
|
|
|
|
|
styleVal => $parameters{"styleVal"}, |
438
|
11
|
|
|
|
|
147
|
capStyle => $parameters{"capStyle"}, |
439
|
|
|
|
|
|
|
point1 => undef, |
440
|
|
|
|
|
|
|
point3 => undef, |
441
|
|
|
|
|
|
|
angle => undef, |
442
|
|
|
|
|
|
|
controlAngle => undef, |
443
|
|
|
|
|
|
|
}; |
444
|
11
|
|
|
|
|
44
|
Graphics::Fig::Parameters::copyArrowParameters($self, \%parameters); |
445
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
# |
447
|
|
|
|
|
|
|
# If "r" or "d" given, set $r to radius. |
448
|
|
|
|
|
|
|
# |
449
|
11
|
|
|
|
|
17
|
my $r; |
450
|
11
|
100
|
|
|
|
33
|
if (defined($parameters{"r"})) { |
|
|
100
|
|
|
|
|
|
451
|
4
|
50
|
|
|
|
11
|
if (defined($parameters{"d"})) { |
452
|
0
|
|
|
|
|
0
|
croak("arc: error: r and d cannot be given together"); |
453
|
|
|
|
|
|
|
} |
454
|
4
|
|
|
|
|
8
|
$r = $parameters{"r"}; |
455
|
|
|
|
|
|
|
|
456
|
|
|
|
|
|
|
} elsif (defined($parameters{"d"})) { |
457
|
3
|
|
|
|
|
7
|
$r = $parameters{"d"} / 2.0; |
458
|
|
|
|
|
|
|
} |
459
|
|
|
|
|
|
|
|
460
|
11
|
|
|
|
|
17
|
my $points = $parameters{"points"}; |
461
|
11
|
100
|
|
|
|
23
|
if (!defined($points)) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
462
|
7
|
50
|
|
|
|
25
|
if (!defined($r)) { |
463
|
0
|
|
|
|
|
0
|
croak("arc: error: r, d or points parameter required"); |
464
|
|
|
|
|
|
|
} |
465
|
7
|
|
|
|
|
23
|
my ($angle, $controlAngle) = &calcAngleParameters(\%parameters); |
466
|
7
|
|
|
|
|
20
|
my ($xc, $yc); |
467
|
7
|
50
|
|
|
|
16
|
if (defined($parameters{"center"})) { |
468
|
0
|
|
|
|
|
0
|
($xc, $yc) = @{$parameters{"center"}}; |
|
0
|
|
|
|
|
0
|
|
469
|
|
|
|
|
|
|
} else { |
470
|
7
|
|
|
|
|
13
|
($xc, $yc) = @{$parameters{"position"}}; |
|
7
|
|
|
|
|
18
|
|
471
|
|
|
|
|
|
|
} |
472
|
7
|
|
|
|
|
9
|
my $rotation; |
473
|
7
|
100
|
|
|
|
16
|
if (!defined($rotation = $parameters{"rotation"})) { |
474
|
3
|
|
|
|
|
6
|
$rotation = 0; |
475
|
|
|
|
|
|
|
} |
476
|
7
|
|
|
|
|
38
|
${$self}{"point1"} = [ $xc + $r * cos($rotation), |
|
7
|
|
|
|
|
16
|
|
477
|
|
|
|
|
|
|
$yc + $r * -sin($rotation) ]; |
478
|
7
|
|
|
|
|
75
|
${$self}{"point3"} = [ $xc + $r * cos($rotation + $angle), |
|
7
|
|
|
|
|
13
|
|
479
|
|
|
|
|
|
|
$yc + $r * -sin($rotation + $angle) ]; |
480
|
7
|
|
|
|
|
13
|
${$self}{"angle"} = $angle; |
|
7
|
|
|
|
|
8
|
|
481
|
7
|
|
|
|
|
12
|
${$self}{"controlAngle"} = $controlAngle; |
|
7
|
|
|
|
|
13
|
|
482
|
|
|
|
|
|
|
|
483
|
4
|
|
|
|
|
22
|
} elsif (scalar(@{$points}) == 1) { |
484
|
1
|
|
|
|
|
6
|
my ($xc, $yc, $x3, $y3); |
485
|
|
|
|
|
|
|
|
486
|
1
|
50
|
|
|
|
12
|
if (defined($parameters{"d"})) { |
487
|
0
|
|
|
|
|
0
|
croak("arc: error: d cannot be given with two points"); |
488
|
|
|
|
|
|
|
} |
489
|
1
|
50
|
|
|
|
6
|
if (defined($parameters{"r"})) { |
490
|
0
|
|
|
|
|
0
|
croak("arc: error: r cannot be given with two points"); |
491
|
|
|
|
|
|
|
} |
492
|
1
|
50
|
|
|
|
4
|
if (defined($parameters{"rotation"})) { |
493
|
0
|
|
|
|
|
0
|
croak("arc: error: radius required with point and rotation"); |
494
|
|
|
|
|
|
|
} |
495
|
1
|
50
|
|
|
|
3
|
if (defined($parameters{"center"})) { |
496
|
1
|
|
|
|
|
2
|
($xc, $yc) = @{$parameters{"center"}}; |
|
1
|
|
|
|
|
4
|
|
497
|
|
|
|
|
|
|
} else { |
498
|
0
|
|
|
|
|
0
|
($xc, $yc) = @{$parameters{"position"}}; |
|
0
|
|
|
|
|
0
|
|
499
|
|
|
|
|
|
|
} |
500
|
1
|
|
|
|
|
5
|
my ($angle, $controlAngle) = &calcAngleParameters(\%parameters); |
501
|
1
|
|
|
|
|
3
|
my $x = ${$points}[0][0] - $xc; |
|
1
|
|
|
|
|
8
|
|
502
|
1
|
|
|
|
|
3
|
my $y = ${$points}[0][1] - $yc; |
|
1
|
|
|
|
|
6
|
|
503
|
1
|
|
|
|
|
3
|
my $c = cos($angle); |
504
|
1
|
|
|
|
|
4
|
my $s = sin($angle); |
505
|
1
|
|
|
|
|
5
|
$x3 = $xc + $c * $x + $s * $y; |
506
|
1
|
|
|
|
|
3
|
$y3 = $yc - $s * $x + $c * $y; |
507
|
1
|
|
|
|
|
2
|
${$self}{"point1"} = ${$points}[0]; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
3
|
|
508
|
1
|
|
|
|
|
3
|
${$self}{"point3"} = [ $x3, $y3 ]; |
|
1
|
|
|
|
|
2
|
|
509
|
1
|
|
|
|
|
2
|
${$self}{"angle"} = $angle; |
|
1
|
|
|
|
|
2
|
|
510
|
1
|
|
|
|
|
3
|
${$self}{"controlAngle"} = $controlAngle; |
|
1
|
|
|
|
|
2
|
|
511
|
|
|
|
|
|
|
|
512
|
3
|
|
|
|
|
9
|
} elsif (scalar(@{$points}) == 2) { |
513
|
1
|
50
|
|
|
|
6
|
if (defined($parameters{"d"})) { |
514
|
0
|
|
|
|
|
0
|
croak("arc: error: d cannot be given with two points"); |
515
|
|
|
|
|
|
|
} |
516
|
1
|
50
|
|
|
|
3
|
if (defined($parameters{"r"})) { |
517
|
0
|
|
|
|
|
0
|
croak("arc: error: r cannot be given with two points"); |
518
|
|
|
|
|
|
|
} |
519
|
1
|
50
|
|
|
|
3
|
if (defined($parameters{"center"})) { |
520
|
0
|
|
|
|
|
0
|
croak("arc: error: center cannot be given with two points"); |
521
|
|
|
|
|
|
|
} |
522
|
1
|
50
|
|
|
|
3
|
if (defined($parameters{"rotation"})) { |
523
|
0
|
|
|
|
|
0
|
croak("arc: error: rotation cannot be given with two points"); |
524
|
|
|
|
|
|
|
} |
525
|
1
|
|
|
|
|
5
|
my ($angle, $controlAngle) = &calcAngleParameters(\%parameters); |
526
|
1
|
|
|
|
|
2
|
${$self}{"point1"} = ${$points}[0]; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
5
|
|
527
|
1
|
|
|
|
|
2
|
${$self}{"point3"} = ${$points}[1]; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
528
|
1
|
|
|
|
|
2
|
${$self}{"angle"} = $angle; |
|
1
|
|
|
|
|
4
|
|
529
|
1
|
|
|
|
|
2
|
${$self}{"controlAngle"} = $controlAngle; |
|
1
|
|
|
|
|
3
|
|
530
|
|
|
|
|
|
|
|
531
|
2
|
|
|
|
|
5
|
} elsif (scalar(@{$points}) == 3) { |
532
|
2
|
50
|
|
|
|
7
|
if (defined($parameters{"d"})) { |
533
|
0
|
|
|
|
|
0
|
croak("arc: error: d cannot be given with three points"); |
534
|
|
|
|
|
|
|
} |
535
|
2
|
50
|
|
|
|
6
|
if (defined($parameters{"r"})) { |
536
|
0
|
|
|
|
|
0
|
croak("arc: error: r cannot be given with three points"); |
537
|
|
|
|
|
|
|
} |
538
|
2
|
50
|
|
|
|
5
|
if (defined($parameters{"direction"})) { |
539
|
0
|
|
|
|
|
0
|
croak("arc: error: direction cannot be given with three points"); |
540
|
|
|
|
|
|
|
} |
541
|
2
|
50
|
|
|
|
10
|
if (defined($parameters{"controlAngle"})) { |
542
|
0
|
|
|
|
|
0
|
croak("arc: error: controlAngle cannot be given with three points"); |
543
|
|
|
|
|
|
|
} |
544
|
2
|
50
|
|
|
|
5
|
if (defined($parameters{"angle"})) { |
545
|
0
|
|
|
|
|
0
|
croak("arc: error: angle cannot be given with three points"); |
546
|
|
|
|
|
|
|
} |
547
|
2
|
|
|
|
|
7
|
my ( $angle, $controlAngle ) = &calcAnglesFromPoints($points); |
548
|
2
|
|
|
|
|
4
|
${$self}{"point1"} = ${$points}[0]; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
5
|
|
549
|
2
|
|
|
|
|
3
|
${$self}{"point3"} = ${$points}[2]; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
4
|
|
550
|
2
|
|
|
|
|
3
|
${$self}{"angle"} = $angle; |
|
2
|
|
|
|
|
5
|
|
551
|
2
|
|
|
|
|
3
|
${$self}{"controlAngle"} = $controlAngle; |
|
2
|
|
|
|
|
4
|
|
552
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
} else { |
554
|
0
|
|
|
|
|
0
|
croak("arc: error: expected between zero and three points"); |
555
|
|
|
|
|
|
|
} |
556
|
11
|
|
33
|
|
|
41
|
my $class = ref($proto) || $proto; |
557
|
11
|
|
|
|
|
23
|
bless($self, $class); |
558
|
11
|
|
|
|
|
18
|
push(@{${$tos}{"objects"}}, $self); |
|
11
|
|
|
|
|
15
|
|
|
11
|
|
|
|
|
28
|
|
559
|
11
|
|
|
|
|
67
|
return $self; |
560
|
|
|
|
|
|
|
} |
561
|
|
|
|
|
|
|
|
562
|
|
|
|
|
|
|
# |
563
|
|
|
|
|
|
|
# Graphics::Fig::Arc::arcto constructor |
564
|
|
|
|
|
|
|
# $proto: prototype |
565
|
|
|
|
|
|
|
# $fig: parent object |
566
|
|
|
|
|
|
|
# @parameters: arc parameters |
567
|
|
|
|
|
|
|
# |
568
|
|
|
|
|
|
|
sub arcto { |
569
|
14
|
|
|
14
|
0
|
25
|
my $proto = shift; |
570
|
14
|
|
|
|
|
18
|
my $fig = shift; |
571
|
|
|
|
|
|
|
|
572
|
|
|
|
|
|
|
# |
573
|
|
|
|
|
|
|
# Parse parameters. |
574
|
|
|
|
|
|
|
# |
575
|
14
|
|
|
|
|
72
|
my %parameters; |
576
|
14
|
|
|
|
|
51
|
my $stack = ${$fig}{"stack"}; |
|
14
|
|
|
|
|
27
|
|
577
|
14
|
|
|
|
|
21
|
my $tos = ${$stack}[$#{$stack}]; |
|
14
|
|
|
|
|
25
|
|
|
14
|
|
|
|
|
19
|
|
578
|
14
|
|
|
|
|
22
|
eval { |
579
|
|
|
|
|
|
|
Graphics::Fig::Parameters::parse($fig, "arcto", |
580
|
|
|
|
|
|
|
\%ArctoParameterTemplate, |
581
|
14
|
|
|
|
|
43
|
${$tos}{"options"}, \%parameters, @_); |
|
14
|
|
|
|
|
42
|
|
582
|
|
|
|
|
|
|
}; |
583
|
14
|
50
|
|
|
|
42
|
if ($@) { |
584
|
0
|
|
|
|
|
0
|
$@ =~ s/ at [^\s]* line \d+\.\n//; |
585
|
0
|
|
|
|
|
0
|
croak("$@"); |
586
|
|
|
|
|
|
|
} |
587
|
|
|
|
|
|
|
|
588
|
|
|
|
|
|
|
# |
589
|
|
|
|
|
|
|
# Construct the object. Undefined parameters are set below. |
590
|
|
|
|
|
|
|
# |
591
|
|
|
|
|
|
|
my $self = { |
592
|
|
|
|
|
|
|
subtype => $parameters{"subtype"}, |
593
|
|
|
|
|
|
|
lineStyle => $parameters{"lineStyle"}, |
594
|
|
|
|
|
|
|
lineThickness => $parameters{"lineThickness"}, |
595
|
|
|
|
|
|
|
penColor => $parameters{"penColor"}, |
596
|
|
|
|
|
|
|
fillColor => $parameters{"fillColor"}, |
597
|
|
|
|
|
|
|
depth => $parameters{"depth"}, |
598
|
|
|
|
|
|
|
areaFill => $parameters{"areaFill"}, |
599
|
|
|
|
|
|
|
styleVal => $parameters{"styleVal"}, |
600
|
14
|
|
|
|
|
134
|
capStyle => $parameters{"capStyle"}, |
601
|
|
|
|
|
|
|
point1 => undef, |
602
|
|
|
|
|
|
|
point3 => undef, |
603
|
|
|
|
|
|
|
angle => undef, |
604
|
|
|
|
|
|
|
controlAngle => undef, |
605
|
|
|
|
|
|
|
}; |
606
|
14
|
|
|
|
|
50
|
Graphics::Fig::Parameters::copyArrowParameters($self, \%parameters); |
607
|
|
|
|
|
|
|
|
608
|
14
|
|
|
|
|
24
|
my $points = $parameters{"points"}; |
609
|
14
|
100
|
|
|
|
33
|
if (!defined($points)) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
610
|
8
|
|
|
|
|
13
|
my ($x3, $y3, $angle, $controlAngle); |
611
|
8
|
100
|
66
|
|
|
28
|
if (defined($parameters{"distance"}) || |
612
|
|
|
|
|
|
|
defined($parameters{"heading"})) { |
613
|
6
|
50
|
|
|
|
14
|
if (defined($parameters{"center"})) { |
614
|
0
|
|
|
|
|
0
|
croak("arcto: error: center cannot be given with distance " . |
615
|
|
|
|
|
|
|
"and heading"); |
616
|
|
|
|
|
|
|
} |
617
|
6
|
50
|
|
|
|
11
|
if (!defined($parameters{"distance"})) { |
618
|
0
|
|
|
|
|
0
|
croak("arcto: error: distance must be given with heading"); |
619
|
|
|
|
|
|
|
} |
620
|
6
|
50
|
|
|
|
14
|
if (!defined($parameters{"heading"})) { |
621
|
0
|
|
|
|
|
0
|
croak("arcto: error: heading must be given with distance"); |
622
|
|
|
|
|
|
|
} |
623
|
6
|
|
|
|
|
15
|
($angle, $controlAngle) = &calcAngleParameters(\%parameters); |
624
|
|
|
|
|
|
|
$x3 = $parameters{"position"}[0] |
625
|
6
|
|
|
|
|
46
|
+ $parameters{"distance"} * cos($parameters{"heading"}); |
626
|
|
|
|
|
|
|
$y3 = $parameters{"position"}[1] |
627
|
6
|
|
|
|
|
19
|
- $parameters{"distance"} * sin($parameters{"heading"}); |
628
|
|
|
|
|
|
|
|
629
|
|
|
|
|
|
|
} else { |
630
|
2
|
50
|
|
|
|
6
|
if (!defined($parameters{"center"})) { |
631
|
0
|
|
|
|
|
0
|
croak("arcto: error: expected distance and heading, center " . |
632
|
|
|
|
|
|
|
"or points"); |
633
|
|
|
|
|
|
|
} |
634
|
2
|
50
|
|
|
|
5
|
if (defined($parameters{"distance"})) { |
635
|
0
|
|
|
|
|
0
|
croak("arcto: error: distance cannot be given with center"); |
636
|
|
|
|
|
|
|
} |
637
|
2
|
50
|
|
|
|
6
|
if (defined($parameters{"heading"})) { |
638
|
0
|
|
|
|
|
0
|
croak("arcto: error: heading cannot be given with center"); |
639
|
|
|
|
|
|
|
} |
640
|
2
|
|
|
|
|
4
|
my ($xc, $yc) = @{$parameters{"center"}}; |
|
2
|
|
|
|
|
5
|
|
641
|
2
|
|
|
|
|
6
|
($angle, $controlAngle) = &calcAngleParameters(\%parameters); |
642
|
2
|
|
|
|
|
18
|
my $x = $parameters{"position"}[0] - $xc; |
643
|
2
|
|
|
|
|
5
|
my $y = $parameters{"position"}[1] - $yc; |
644
|
2
|
|
|
|
|
6
|
my $c = cos($angle); |
645
|
2
|
|
|
|
|
5
|
my $s = sin($angle); |
646
|
2
|
|
|
|
|
7
|
$x3 = $xc + $c * $x + $s * $y; |
647
|
2
|
|
|
|
|
5
|
$y3 = $yc - $s * $x + $c * $y; |
648
|
|
|
|
|
|
|
} |
649
|
8
|
|
|
|
|
14
|
${$self}{"point1"} = $parameters{"position"}; |
|
8
|
|
|
|
|
23
|
|
650
|
8
|
|
|
|
|
19
|
${$self}{"point3"} = [ $x3, $y3 ]; |
|
8
|
|
|
|
|
11
|
|
651
|
8
|
|
|
|
|
14
|
${$self}{"angle"} = $angle; |
|
8
|
|
|
|
|
9
|
|
652
|
8
|
|
|
|
|
15
|
${$self}{"controlAngle"} = $controlAngle; |
|
8
|
|
|
|
|
15
|
|
653
|
|
|
|
|
|
|
|
654
|
6
|
|
|
|
|
17
|
} elsif (scalar(@{$points} == 1)) { |
655
|
3
|
50
|
|
|
|
9
|
if (defined($parameters{"center"})) { |
656
|
0
|
|
|
|
|
0
|
croak("arcto: error: center cannot be given with points"); |
657
|
|
|
|
|
|
|
} |
658
|
3
|
50
|
|
|
|
9
|
if (defined($parameters{"distance"})) { |
659
|
0
|
|
|
|
|
0
|
croak("arcto: error: distance cannot be given with points"); |
660
|
|
|
|
|
|
|
} |
661
|
3
|
50
|
|
|
|
8
|
if (defined($parameters{"heading"})) { |
662
|
0
|
|
|
|
|
0
|
croak("arcto: error: heading cannot be given with points"); |
663
|
|
|
|
|
|
|
} |
664
|
3
|
|
|
|
|
14
|
my ($angle, $controlAngle) = &calcAngleParameters(\%parameters); |
665
|
3
|
|
|
|
|
7
|
${$self}{"point1"} = $parameters{"position"}; |
|
3
|
|
|
|
|
7
|
|
666
|
3
|
|
|
|
|
4
|
${$self}{"point3"} = $parameters{"points"}[0]; |
|
3
|
|
|
|
|
6
|
|
667
|
3
|
|
|
|
|
5
|
${$self}{"angle"} = $angle; |
|
3
|
|
|
|
|
4
|
|
668
|
3
|
|
|
|
|
7
|
${$self}{"controlAngle"} = $controlAngle; |
|
3
|
|
|
|
|
4
|
|
669
|
|
|
|
|
|
|
|
670
|
3
|
|
|
|
|
9
|
} elsif (scalar(@{$points} == 2)) { |
671
|
3
|
50
|
|
|
|
7
|
if (defined($parameters{"angle"})) { |
672
|
0
|
|
|
|
|
0
|
croak("arcto: error: angle cannot be given with two points"); |
673
|
|
|
|
|
|
|
} |
674
|
3
|
50
|
|
|
|
8
|
if (defined($parameters{"center"})) { |
675
|
0
|
|
|
|
|
0
|
croak("arcto: error: center cannot be given with points"); |
676
|
|
|
|
|
|
|
} |
677
|
3
|
50
|
|
|
|
6
|
if (defined($parameters{"controlAngle"})) { |
678
|
0
|
|
|
|
|
0
|
croak("arcto: error: controlAngle cannot be given with two points"); |
679
|
|
|
|
|
|
|
} |
680
|
3
|
50
|
|
|
|
7
|
if (defined($parameters{"direction"})) { |
681
|
0
|
|
|
|
|
0
|
croak("arcto: error: direction cannot be given with two points"); |
682
|
|
|
|
|
|
|
} |
683
|
3
|
50
|
|
|
|
6
|
if (defined($parameters{"distance"})) { |
684
|
0
|
|
|
|
|
0
|
croak("arcto: error: distance cannot be given with points"); |
685
|
|
|
|
|
|
|
} |
686
|
3
|
50
|
|
|
|
8
|
if (defined($parameters{"heading"})) { |
687
|
0
|
|
|
|
|
0
|
croak("arcto: error: heading cannot be given with points"); |
688
|
|
|
|
|
|
|
} |
689
|
|
|
|
|
|
|
my ( $angle, $controlAngle ) = &calcAnglesFromPoints([ |
690
|
3
|
|
|
|
|
41
|
$parameters{"position"}, ${$points}[0], ${$points}[1] ]); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
11
|
|
691
|
3
|
|
|
|
|
8
|
${$self}{"point1"} = $parameters{"position"}; |
|
3
|
|
|
|
|
7
|
|
692
|
3
|
|
|
|
|
4
|
${$self}{"point3"} = ${$points}[1]; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
21
|
|
693
|
3
|
|
|
|
|
4
|
${$self}{"angle"} = $angle; |
|
3
|
|
|
|
|
6
|
|
694
|
3
|
|
|
|
|
4
|
${$self}{"controlAngle"} = $controlAngle; |
|
3
|
|
|
|
|
6
|
|
695
|
|
|
|
|
|
|
|
696
|
|
|
|
|
|
|
} else { |
697
|
0
|
|
|
|
|
0
|
croak("arcto: error: expected point"); |
698
|
|
|
|
|
|
|
} |
699
|
14
|
|
|
|
|
19
|
${$tos}{"options"}{"position"} = ${$self}{"point3"}; |
|
14
|
|
|
|
|
24
|
|
|
14
|
|
|
|
|
22
|
|
700
|
|
|
|
|
|
|
|
701
|
14
|
|
33
|
|
|
46
|
my $class = ref($proto) || $proto; |
702
|
14
|
|
|
|
|
25
|
bless($self, $class); |
703
|
14
|
|
|
|
|
28
|
push(@{${$tos}{"objects"}}, $self); |
|
14
|
|
|
|
|
27
|
|
|
14
|
|
|
|
|
34
|
|
704
|
14
|
|
|
|
|
75
|
return $self; |
705
|
|
|
|
|
|
|
} |
706
|
|
|
|
|
|
|
|
707
|
|
|
|
|
|
|
# |
708
|
|
|
|
|
|
|
# Graphics::Fig::Arc::translate |
709
|
|
|
|
|
|
|
# $self: object |
710
|
|
|
|
|
|
|
# $parameters: reference to parameter hash |
711
|
|
|
|
|
|
|
# |
712
|
|
|
|
|
|
|
sub translate { |
713
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
714
|
1
|
|
|
|
|
2
|
my $parameters = shift; |
715
|
|
|
|
|
|
|
|
716
|
1
|
|
|
|
|
2
|
( ${$self}{"point1"}, ${$self}{"point3"} ) = |
|
1
|
|
|
|
|
4
|
|
717
|
|
|
|
|
|
|
Graphics::Fig::Parameters::translatePoints( |
718
|
1
|
|
|
|
|
2
|
$parameters, ${$self}{"point1"}, ${$self}{"point3"} ); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
4
|
|
719
|
|
|
|
|
|
|
|
720
|
1
|
|
|
|
|
3
|
return 1; |
721
|
|
|
|
|
|
|
} |
722
|
|
|
|
|
|
|
|
723
|
|
|
|
|
|
|
# |
724
|
|
|
|
|
|
|
# Graphics::Fig::Arc::rotate |
725
|
|
|
|
|
|
|
# $self: object |
726
|
|
|
|
|
|
|
# $parameters: reference to parameter hash |
727
|
|
|
|
|
|
|
# |
728
|
|
|
|
|
|
|
sub rotate { |
729
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
730
|
1
|
|
|
|
|
2
|
my $parameters = shift; |
731
|
1
|
|
|
|
|
1
|
my $rotation = ${$parameters}{"rotation"}; |
|
1
|
|
|
|
|
2
|
|
732
|
|
|
|
|
|
|
|
733
|
1
|
|
|
|
|
2
|
( ${$self}{"point1"}, ${$self}{"point3"} ) = |
|
1
|
|
|
|
|
3
|
|
734
|
|
|
|
|
|
|
Graphics::Fig::Parameters::rotatePoints( |
735
|
1
|
|
|
|
|
3
|
$parameters, ${$self}{"point1"}, ${$self}{"point3"} ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
736
|
|
|
|
|
|
|
|
737
|
1
|
|
|
|
|
3
|
return 1; |
738
|
|
|
|
|
|
|
} |
739
|
|
|
|
|
|
|
|
740
|
|
|
|
|
|
|
# |
741
|
|
|
|
|
|
|
# Graphics::Fig::Arc::scale |
742
|
|
|
|
|
|
|
# $self: object |
743
|
|
|
|
|
|
|
# $parameters: reference to parameter hash |
744
|
|
|
|
|
|
|
# |
745
|
|
|
|
|
|
|
sub scale { |
746
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
747
|
1
|
|
|
|
|
2
|
my $parameters = shift; |
748
|
1
|
|
|
|
|
2
|
my $scale = ${$parameters}{"scale"}; |
|
1
|
|
|
|
|
3
|
|
749
|
1
|
50
|
|
|
|
5
|
die unless defined($scale); |
750
|
1
|
|
|
|
|
2
|
my $u = ${$scale}[0]; |
|
1
|
|
|
|
|
3
|
|
751
|
1
|
|
|
|
|
1
|
my $v = ${$scale}[1]; |
|
1
|
|
|
|
|
2
|
|
752
|
|
|
|
|
|
|
|
753
|
|
|
|
|
|
|
# |
754
|
|
|
|
|
|
|
# Simple case: scale proportionally. |
755
|
|
|
|
|
|
|
# |
756
|
1
|
50
|
|
|
|
6
|
if (abs($u) == abs($v)) { |
757
|
0
|
|
|
|
|
0
|
( ${$self}{"point1"}, ${$self}{"point3"} ) = |
|
0
|
|
|
|
|
0
|
|
758
|
|
|
|
|
|
|
Graphics::Fig::Parameters::scalePoints( |
759
|
0
|
|
|
|
|
0
|
$parameters, ${$self}{"point1"}, ${$self}{"point3"} ); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
760
|
|
|
|
|
|
|
|
761
|
|
|
|
|
|
|
# |
762
|
|
|
|
|
|
|
# If mirrored, invert the direction. |
763
|
|
|
|
|
|
|
# |
764
|
0
|
0
|
|
|
|
0
|
if ($u * $v < 0) { |
765
|
0
|
|
|
|
|
0
|
${$self}{"angle"} *= -1; |
|
0
|
|
|
|
|
0
|
|
766
|
0
|
|
|
|
|
0
|
${$self}{"controlAngle"} *= -1; |
|
0
|
|
|
|
|
0
|
|
767
|
|
|
|
|
|
|
} |
768
|
|
|
|
|
|
|
|
769
|
|
|
|
|
|
|
# |
770
|
|
|
|
|
|
|
# General case: find a new arc that passes through the three scaled |
771
|
|
|
|
|
|
|
# points. |
772
|
|
|
|
|
|
|
# |
773
|
|
|
|
|
|
|
} else { |
774
|
1
|
|
|
|
|
3
|
my $point1 = ${$self}{"point1"}; |
|
1
|
|
|
|
|
2
|
|
775
|
1
|
|
|
|
|
2
|
my $point3 = ${$self}{"point3"}; |
|
1
|
|
|
|
|
3
|
|
776
|
1
|
|
|
|
|
2
|
my ( $old_center, $point2 ) = &findPoint2($self); |
777
|
1
|
|
|
|
|
5
|
my @newPoints = Graphics::Fig::Parameters::scalePoints($parameters, |
778
|
|
|
|
|
|
|
$point1, $point2, $point3 ); |
779
|
1
|
|
|
|
|
4
|
my ( $angle, $controlAngle ) = &calcAnglesFromPoints(\@newPoints); |
780
|
|
|
|
|
|
|
|
781
|
1
|
|
|
|
|
2
|
${$self}{"point1"} = $newPoints[0]; |
|
1
|
|
|
|
|
3
|
|
782
|
1
|
|
|
|
|
2
|
${$self}{"point3"} = $newPoints[2]; |
|
1
|
|
|
|
|
2
|
|
783
|
1
|
|
|
|
|
2
|
${$self}{"angle"} = $angle; |
|
1
|
|
|
|
|
2
|
|
784
|
1
|
|
|
|
|
2
|
${$self}{"controlAngle"} = $controlAngle; |
|
1
|
|
|
|
|
6
|
|
785
|
|
|
|
|
|
|
} |
786
|
|
|
|
|
|
|
} |
787
|
|
|
|
|
|
|
|
788
|
|
|
|
|
|
|
# |
789
|
|
|
|
|
|
|
# Graphics::Fig::Arc::crosses_axis: return positive if a CCW arc |
790
|
|
|
|
|
|
|
# intersects the given axis (helper for getbbox) |
791
|
|
|
|
|
|
|
# $point1: first point |
792
|
|
|
|
|
|
|
# $point3: final point |
793
|
|
|
|
|
|
|
# $axis: axis |
794
|
|
|
|
|
|
|
# |
795
|
|
|
|
|
|
|
sub crosses_axis { |
796
|
4
|
|
|
4
|
0
|
8
|
my $point1 = shift; |
797
|
4
|
|
|
|
|
12
|
my $point3 = shift; |
798
|
4
|
|
|
|
|
7
|
my $axis = shift; |
799
|
4
|
|
|
|
|
5
|
my $x1 = ${$point1}[0]; |
|
4
|
|
|
|
|
9
|
|
800
|
4
|
|
|
|
|
4
|
my $y1 = ${$point1}[1]; |
|
4
|
|
|
|
|
8
|
|
801
|
4
|
|
|
|
|
6
|
my $x3 = ${$point3}[0]; |
|
4
|
|
|
|
|
5
|
|
802
|
4
|
|
|
|
|
5
|
my $y3 = ${$point3}[1]; |
|
4
|
|
|
|
|
7
|
|
803
|
4
|
|
|
|
|
5
|
my $x = ${$axis}[0]; |
|
4
|
|
|
|
|
7
|
|
804
|
4
|
|
|
|
|
5
|
my $y = ${$axis}[1]; |
|
4
|
|
|
|
|
5
|
|
805
|
|
|
|
|
|
|
|
806
|
|
|
|
|
|
|
# Find z component of cross product of (point1 - axis) and (point2 - axis). |
807
|
4
|
|
|
|
|
26
|
return $x1 * $y3 - $x3 * $y1 + ($y1 - $y3) * $x + ($x3 - $x1) * $y; |
808
|
|
|
|
|
|
|
} |
809
|
|
|
|
|
|
|
|
810
|
|
|
|
|
|
|
# |
811
|
|
|
|
|
|
|
# Graphics::Fig::Arc::getbbox: return [[xmin, ymin], [xmax, ymax]] |
812
|
|
|
|
|
|
|
# $self: object |
813
|
|
|
|
|
|
|
# $parameters: getbbox parameters |
814
|
|
|
|
|
|
|
# |
815
|
|
|
|
|
|
|
sub getbbox { |
816
|
1
|
|
|
1
|
0
|
3
|
my $self = shift; |
817
|
1
|
|
|
|
|
1
|
my $parameters = shift; |
818
|
|
|
|
|
|
|
|
819
|
1
|
|
|
|
|
2
|
my $point1 = ${$self}{"point1"}; |
|
1
|
|
|
|
|
2
|
|
820
|
1
|
|
|
|
|
2
|
my $point3 = ${$self}{"point3"}; |
|
1
|
|
|
|
|
3
|
|
821
|
1
|
|
|
|
|
2
|
my $angle = ${$self}{"angle"}; |
|
1
|
|
|
|
|
2
|
|
822
|
1
|
|
|
|
|
2
|
my $x1 = ${$point1}[0]; |
|
1
|
|
|
|
|
15
|
|
823
|
1
|
|
|
|
|
3
|
my $y1 = ${$point1}[1]; |
|
1
|
|
|
|
|
2
|
|
824
|
1
|
|
|
|
|
2
|
my $x3 = ${$point3}[0]; |
|
1
|
|
|
|
|
2
|
|
825
|
1
|
|
|
|
|
2
|
my $y3 = ${$point3}[1]; |
|
1
|
|
|
|
|
2
|
|
826
|
|
|
|
|
|
|
|
827
|
|
|
|
|
|
|
# |
828
|
|
|
|
|
|
|
# Find the center and radius. |
829
|
|
|
|
|
|
|
# |
830
|
1
|
|
|
|
|
5
|
my $half_cot = cot($angle / 2) / 2; |
831
|
1
|
|
|
|
|
20
|
my $xc = $x1 + ($x3 - $x1) / 2 + ($y3 - $y1) * $half_cot; |
832
|
1
|
|
|
|
|
4
|
my $yc = $y1 + ($y3 - $y1) / 2 - ($x3 - $x1) * $half_cot; |
833
|
1
|
|
|
|
|
2
|
my $dx = $x1 - $xc; |
834
|
1
|
|
|
|
|
1
|
my $dy = $y1 - $yc; |
835
|
1
|
|
|
|
|
2
|
my $r = sqrt($dx * $dx + $dy * $dy); |
836
|
|
|
|
|
|
|
|
837
|
|
|
|
|
|
|
# |
838
|
|
|
|
|
|
|
# First, find the bounding box of the endpoints. Then for each |
839
|
|
|
|
|
|
|
# axis the arc crosses, expand the box as needed. |
840
|
|
|
|
|
|
|
# |
841
|
1
|
|
|
|
|
4
|
my $bbox = Graphics::Fig::Parameters::getbboxFromPoints($point1, $point3); |
842
|
1
|
50
|
|
|
|
8
|
if (&crosses_axis($point1, $point3, [ $xc - $r, $yc ]) * $angle > 0) { |
843
|
0
|
0
|
|
|
|
0
|
if ($xc - $r < ${$bbox}[0][0]) { |
|
0
|
|
|
|
|
0
|
|
844
|
0
|
|
|
|
|
0
|
${$bbox}[0][0] = $xc - $r; |
|
0
|
|
|
|
|
0
|
|
845
|
|
|
|
|
|
|
} |
846
|
|
|
|
|
|
|
} |
847
|
1
|
50
|
|
|
|
4
|
if (&crosses_axis($point1, $point3, [ $xc, $yc - $r ]) * $angle > 0) { |
848
|
1
|
50
|
|
|
|
2
|
if ($yc - $r < ${$bbox}[0][1]) { |
|
1
|
|
|
|
|
19
|
|
849
|
1
|
|
|
|
|
3
|
${$bbox}[0][1] = $yc - $r; |
|
1
|
|
|
|
|
3
|
|
850
|
|
|
|
|
|
|
} |
851
|
|
|
|
|
|
|
} |
852
|
1
|
50
|
|
|
|
5
|
if (&crosses_axis($point1, $point3, [ $xc + $r, $yc ]) * $angle > 0) { |
853
|
1
|
50
|
|
|
|
2
|
if ($xc + $r > ${$bbox}[1][0]) { |
|
1
|
|
|
|
|
3
|
|
854
|
1
|
|
|
|
|
2
|
${$bbox}[1][0] = $xc + $r; |
|
1
|
|
|
|
|
2
|
|
855
|
|
|
|
|
|
|
} |
856
|
|
|
|
|
|
|
} |
857
|
1
|
50
|
|
|
|
4
|
if (&crosses_axis($point1, $point3, [ $xc, $yc + $r ]) * $angle > 0) { |
858
|
0
|
0
|
|
|
|
0
|
if ($yc + $r > ${$bbox}[1][1]) { |
|
0
|
|
|
|
|
0
|
|
859
|
0
|
|
|
|
|
0
|
${$bbox}[1][1] = $yc + $r; |
|
0
|
|
|
|
|
0
|
|
860
|
|
|
|
|
|
|
} |
861
|
|
|
|
|
|
|
} |
862
|
1
|
|
|
|
|
8
|
return $bbox; |
863
|
|
|
|
|
|
|
} |
864
|
|
|
|
|
|
|
|
865
|
|
|
|
|
|
|
# |
866
|
|
|
|
|
|
|
# Graphics::Fig::Arc::print |
867
|
|
|
|
|
|
|
# $self: object |
868
|
|
|
|
|
|
|
# $fh: reference to output file handle |
869
|
|
|
|
|
|
|
# $parameters: save parameters |
870
|
|
|
|
|
|
|
# |
871
|
|
|
|
|
|
|
sub print { |
872
|
25
|
|
|
25
|
0
|
41
|
my $self = shift; |
873
|
25
|
|
|
|
|
43
|
my $fh = shift; |
874
|
25
|
|
|
|
|
41
|
my $parameters = shift; |
875
|
|
|
|
|
|
|
|
876
|
25
|
|
|
|
|
56
|
my $figPerInch = Graphics::Fig::_figPerInch($parameters); |
877
|
25
|
|
|
|
|
36
|
my $subtype = ${$self}{"subtype"}; |
|
25
|
|
|
|
|
55
|
|
878
|
25
|
|
|
|
|
43
|
my $direction = ${$self}{"angle"} >= 0; |
|
25
|
|
|
|
|
51
|
|
879
|
25
|
|
|
|
|
34
|
my $point1 = ${$self}{"point1"}; |
|
25
|
|
|
|
|
41
|
|
880
|
25
|
|
|
|
|
54
|
my ( $center, $point2 ) = &findPoint2($self); |
881
|
25
|
|
|
|
|
40
|
my $point3 = ${$self}{"point3"}; |
|
25
|
|
|
|
|
56
|
|
882
|
|
|
|
|
|
|
|
883
|
|
|
|
|
|
|
# |
884
|
|
|
|
|
|
|
# Print |
885
|
|
|
|
|
|
|
# |
886
|
|
|
|
|
|
|
printf $fh ("5 %d %d %.0f %d %d %d -1 %d %.3f %d %d %d %d ". |
887
|
|
|
|
|
|
|
"%.0f %.0f %.0f %.0f %.0f %.0f %.0f %.0f\n", |
888
|
|
|
|
|
|
|
$subtype, |
889
|
25
|
|
|
|
|
39
|
${$self}{"lineStyle"}, |
890
|
25
|
|
|
|
|
43
|
${$self}{"lineThickness"} * 80.0, |
891
|
25
|
|
|
|
|
38
|
${$self}{"penColor"}, |
892
|
25
|
|
|
|
|
30
|
${$self}{"fillColor"}, |
893
|
25
|
|
|
|
|
42
|
${$self}{"depth"}, |
894
|
25
|
|
|
|
|
33
|
${$self}{"areaFill"}, |
895
|
25
|
|
|
|
|
32
|
${$self}{"styleVal"} * 80.0, |
896
|
25
|
|
|
|
|
41
|
${$self}{"capStyle"}, |
897
|
|
|
|
|
|
|
$direction, |
898
|
25
|
|
|
|
|
52
|
defined(${$self}{"fArrow"}) ? 1 : 0, |
899
|
25
|
|
|
|
|
45
|
defined(${$self}{"bArrow"}) ? 1 : 0, |
900
|
25
|
|
|
|
|
42
|
${$center}[0] * $figPerInch, ${$center}[1] * $figPerInch, |
|
25
|
|
|
|
|
33
|
|
901
|
25
|
|
|
|
|
47
|
${$point1}[0] * $figPerInch, ${$point1}[1] * $figPerInch, |
|
25
|
|
|
|
|
32
|
|
902
|
25
|
|
|
|
|
44
|
${$point2}[0] * $figPerInch, ${$point2}[1] * $figPerInch, |
|
25
|
|
|
|
|
31
|
|
903
|
25
|
100
|
|
|
|
40
|
${$point3}[0] * $figPerInch, ${$point3}[1] * $figPerInch); |
|
25
|
100
|
|
|
|
40
|
|
|
25
|
|
|
|
|
251
|
|
904
|
25
|
|
|
|
|
106
|
Graphics::Fig::Parameters::printArrowParameters($self, $fh, $parameters); |
905
|
|
|
|
|
|
|
} |
906
|
|
|
|
|
|
|
|
907
|
|
|
|
|
|
|
1; |