1 package LaTeX::TikZ::Set::Arc;
8 LaTeX::TikZ::Set::Arc - A combined set object representing an arc.
16 our $VERSION = '0.02';
22 use LaTeX::TikZ::Point;
24 use LaTeX::TikZ::Set::Circle;
25 use LaTeX::TikZ::Set::Polyline;
27 use LaTeX::TikZ::Interface;
29 use LaTeX::TikZ::Tools;
31 use Mouse::Util::TypeConstraints 'find_type_constraint';
33 my $ltp_tc = find_type_constraint('LaTeX::TikZ::Point::Autocoerce');
35 LaTeX::TikZ::Interface->register(
38 Carp::confess('Tikz->arc($first_point, $second_point, $center)') if @_ < 3;
42 my $p = $ltp_tc->coerce($_);
43 $ltp_tc->assert_valid($p);
44 $_ = Math::Complex->make($p->x, $p->y);
48 Carp::confess("The two first points aren't on a circle of center the last")
49 unless LaTeX::TikZ::Tools::numeq(abs($b - $c), $r);
51 my $set = LaTeX::TikZ::Set::Circle->new(
58 my $theta = (($b - $c) / ($a - $c))->arg;
59 my $points = int(abs($theta) / abs(Math::Trig::acos(0.95)));
60 $theta /= $points + 1;
61 my $rho = (1 / cos($theta)) / (1 - $factor);
63 my $ua = ($a - $c) * (1 - $factor) + $c;
64 my $ub = ($b - $c) * (1 - $factor) + $c;
66 my @outside = map { $_ * $rho + $c } (
68 (map { ($a - $c) * Math::Complex->emake(1, $_ * $theta) } 1 .. $points),
73 LaTeX::TikZ::Set::Polyline->new(
74 points => [ $ua, @outside, $ub ],
83 L<LaTeX::TikZ>, L<LaTeX::TikZ::Set>.
87 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
89 You can contact me by mail or on C<irc.perl.org> (vincent).
93 Please report any bugs or feature requests to C<bug-latex-tikz at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=LaTeX-TikZ>.
94 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
98 You can find documentation for this module with the perldoc command.
102 =head1 COPYRIGHT & LICENSE
104 Copyright 2010 Vincent Pit, all rights reserved.
106 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
110 1; # End of LaTeX::TikZ::Set::Arc