1 package LaTeX::TikZ::Tools;
8 LaTeX::TikZ::Tools - Miscellaneous tools for LaTeX::TikZ classes.
16 our $VERSION = '0.02';
18 use Mouse::Util::TypeConstraints 'find_type_constraint';
24 The numerical accuracy enforced by L</numeq>, L</numcmp> and L</numround>.
25 It is currently set to C<1e-10>.
29 use constant EPS => 1e-10;
33 =head2 C<numeq $x, $y>
35 Returns true if and only if C<$x> and C<$y> are equal up to L</EPS>.
39 sub numeq { abs($_[0] - $_[1]) < EPS }
41 =head2 C<numcmp $x, $y>
43 Returns a negative number, zero, or a positive number when C<$x> is respectively smaller than, equal to, or greater than C<$y> up to L</EPS>.
47 sub numcmp { $_[0] < $_[1] - EPS ? -1 : $_[0] > $_[1] + EPS ? 1 : 0 }
51 Returns the closest integer from C<$x> up to L</EPS>.
58 $x + EPS < $i + 0.5 ? $i : $i + 1;
61 =head2 C<type_constraint $class>
63 Finds the type constraint for C<$class> by first trying to load the relevant F<.pm> file.
73 unless ($INC{$file}) {
76 local $SIG{__DIE__}; # See LaTeX::TikZ::Meta::TypeConstraint::Autocoerce
81 find_type_constraint($class);
90 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
92 You can contact me by mail or on C<irc.perl.org> (vincent).
96 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>.
97 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
101 You can find documentation for this module with the perldoc command.
105 =head1 COPYRIGHT & LICENSE
107 Copyright 2010 Vincent Pit, all rights reserved.
109 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
113 1; # End of LaTeX::TikZ::Tools