line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Math::Geometry::Construction::Derivate::IntersectionCircleCircle; |
2
|
1
|
|
|
1
|
|
1936
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
extends 'Math::Geometry::Construction::Derivate'; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use 5.008008; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Math::Geometry::Construction::Types qw(CircleCircle); |
8
|
|
|
|
|
|
|
use Carp; |
9
|
|
|
|
|
|
|
use Math::Vector::Real; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
C<Math::Geometry::Construction::Derivate::IntersectionCircleCircle> - circle circle intersection |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 VERSION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Version 0.024 |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = '0.024'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
########################################################################### |
25
|
|
|
|
|
|
|
# # |
26
|
|
|
|
|
|
|
# Accessors # |
27
|
|
|
|
|
|
|
# # |
28
|
|
|
|
|
|
|
########################################################################### |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has 'input' => (isa => CircleCircle, |
31
|
|
|
|
|
|
|
is => 'bare', |
32
|
|
|
|
|
|
|
traits => ['Array'], |
33
|
|
|
|
|
|
|
required => 1, |
34
|
|
|
|
|
|
|
handles => {count_input => 'count', |
35
|
|
|
|
|
|
|
input => 'elements', |
36
|
|
|
|
|
|
|
single_input => 'accessor'}); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
########################################################################### |
39
|
|
|
|
|
|
|
# # |
40
|
|
|
|
|
|
|
# Retrieve Data # |
41
|
|
|
|
|
|
|
# # |
42
|
|
|
|
|
|
|
########################################################################### |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub calculate_positions { |
45
|
|
|
|
|
|
|
my ($self) = @_; |
46
|
|
|
|
|
|
|
my @circles = $self->input; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# currently assuming that points have to be defined |
49
|
|
|
|
|
|
|
my @center_p = map { $_->center->position } @circles; |
50
|
|
|
|
|
|
|
my @radii = map { $_->radius } @circles; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
foreach(@center_p, @radii) { return if(!defined($_)) } |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my $distance = $center_p[1] - $center_p[0]; |
55
|
|
|
|
|
|
|
my $d = abs($distance); |
56
|
|
|
|
|
|
|
return if($d == 0); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $parallel = $distance / $d; |
59
|
|
|
|
|
|
|
my $normal = $parallel->normal_base; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
my $x = ($d**2 - $radii[1]**2 + $radii[0]**2) / (2 * $d); |
62
|
|
|
|
|
|
|
my $rad = $radii[0]**2 - $x**2; |
63
|
|
|
|
|
|
|
return if($rad < 0); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my $y = sqrt($rad); |
66
|
|
|
|
|
|
|
return($center_p[0] + $parallel * $x + $normal * $y, |
67
|
|
|
|
|
|
|
$center_p[0] + $parallel * $x - $normal * $y); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
########################################################################### |
71
|
|
|
|
|
|
|
# # |
72
|
|
|
|
|
|
|
# Change Data # |
73
|
|
|
|
|
|
|
# # |
74
|
|
|
|
|
|
|
########################################################################### |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub register_derived_point { |
77
|
|
|
|
|
|
|
my ($self, $point) = @_; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
foreach($self->input) { $_->register_point($point) } |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__END__ |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=pod |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 SYNOPSIS |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 DESCRIPTION |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 INTERFACE |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 Public Attributes |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 Methods for Users |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 Methods for Subclass Developers |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 AUTHOR |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Lutz Gehlen, C<< <perl at lutzgehlen.de> >> |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Copyright 2011, 2013 Lutz Gehlen. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
114
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
115
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |
121
|
|
|
|
|
|
|
|