#
sub power {
my ($z1, $z2, $inverted) = @_;
- _zerotozero if ($z1 == 0 and $z2 == 0);
- return 1 if ($z1 == 1);
- return 0 if ($z2 == 0);
+ my $z1z = $z1 == 0;
+ my $z2z = $z2 == 0;
+ _zerotozero if ($z1z and $z2z);
+ if ($inverted) {
+ return 0 if ($z2z);
+ return 1 if ($z1z or $z2 == 1);
+ } else {
+ return 0 if ($z1z);
+ return 1 if ($z2z or $z1 == 1);
+ }
$z2 = cplx($z2) unless ref $z2;
unless (defined $inverted) {
my $z3 = exp($z2 * log $z1);
=head1 AUTHORS
- Raphael Manfredi <F<Raphael_Manfredi@grenoble.hp.com>>
- Jarkko Hietaniemi <F<jhi@iki.fi>>
+Raphael Manfredi <F<Raphael_Manfredi@grenoble.hp.com>> and
+Jarkko Hietaniemi <F<jhi@iki.fi>>.
=cut
$VERSION = 1.00;
-my @angcnv = qw(rad_to_deg rad_to_grad
- deg_to_rad deg_to_grad
- grad_to_rad grad_to_deg);
+my @angcnv = qw(rad2deg rad2grad
+ deg2rad deg2grad
+ grad2rad grad2deg);
@EXPORT = (@{$Math::Complex::EXPORT_TAGS{'trig'}},
@angcnv);
# Angle conversions.
#
-sub rad_to_deg ($) { remt(RD * $_[0], 360) }
+sub rad2deg ($) { remt(RD * $_[0], 360) }
-sub deg_to_rad ($) { remt(DR * $_[0], pi2) }
+sub deg2rad ($) { remt(DR * $_[0], pi2) }
-sub grad_to_deg ($) { remt(GD * $_[0], 360) }
+sub grad2deg ($) { remt(GD * $_[0], 360) }
-sub deg_to_grad ($) { remt(DG * $_[0], 400) }
+sub deg2grad ($) { remt(DG * $_[0], 400) }
-sub rad_to_grad ($) { remt(RG * $_[0], 400) }
+sub rad2grad ($) { remt(RG * $_[0], 400) }
-sub grad_to_rad ($) { remt(GR * $_[0], pi2) }
+sub grad2rad ($) { remt(GR * $_[0], pi2) }
=head1 NAME
$halfpi = pi/2;
- $rad = deg_to_rad(120);
+ $rad = deg2rad(120);
=head1 DESCRIPTION
(Plane, 2-dimensional) angles may be converted with the following functions.
- $radians = deg_to_rad($degrees);
- $radians = grad_to_rad($gradians);
+ $radians = deg2rad($degrees);
+ $radians = grad2rad($gradians);
- $degrees = rad_to_deg($radians);
- $degrees = grad_to_deg($gradians);
+ $degrees = rad2deg($radians);
+ $degrees = grad2deg($gradians);
- $gradians = deg_to_grad($degrees);
- $gradians = rad_to_grad($radians);
+ $gradians = deg2grad($degrees);
+ $gradians = rad2grad($radians);
The full circle is 2 I<pi> radians or I<360> degrees or I<400> gradians.
=head1 AUTHORS
- Jarkko Hietaniemi <F<jhi@iki.fi>>
- Raphael Manfredi <F<Raphael_Manfredi@grenoble.hp.com>>
+Jarkko Hietaniemi <F<jhi@iki.fi>> and
+Raphael Manfredi <F<Raphael_Manfredi@grenoble.hp.com>>.
=cut
abs($_[0] - $_[1]) < (defined $_[2] ? $_[2] : $eps);
}
-print "1..6\n";
+print "1..7\n";
$x = 0.9;
print 'not ' unless (near(tan($x), sin($x) / cos($x)));
near($z, -1.31695789692482));
print "ok 5\n";
-print 'not ' unless (near(deg_to_rad(90), pi/2));
+print 'not ' unless (near(deg2rad(90), pi/2));
print "ok 6\n";
+print 'not ' unless (near(rad2deg(pi), 180));
+print "ok 7\n";
+
# eof