NAME
Acme::ExtUtils::XSOne::Test::Calculator::Trig - Trigonometric functions
SYNOPSIS
# Import specific functions
use Acme::ExtUtils::XSOne::Test::Calculator::Trig qw(sin_val cos_val deg_to_rad);
my $sin = sin_val(3.14159/2); # ~1.0
my $cos = cos_val(0); # 1.0
my $rad = deg_to_rad(180); # ~3.14159
# Or use fully qualified names
use Acme::ExtUtils::XSOne::Test::Calculator;
my $tan = Acme::ExtUtils::XSOne::Test::Calculator::Trig::tan_val(0.785398); # ~1.0
my $deg = Acme::ExtUtils::XSOne::Test::Calculator::Trig::rad_to_deg(3.14159); # ~180
EXPORTABLE FUNCTIONS
All functions can be imported by name:
sin_val cos_val tan_val asin_val acos_val atan_val atan2_val
deg_to_rad rad_to_deg hypot_val normalize_angle
sec_val csc_val cot_val is_valid_asin_arg
DESCRIPTION
This module provides trigonometric functions as part of the Acme::ExtUtils::XSOne::Test::Calculator distribution. All angles are in radians unless otherwise noted. Operations record their results in the shared calculation history.
FUNCTIONS
sin_val
my $result = sin_val($radians);
Returns the sine of $radians.
cos_val
my $result = cos_val($radians);
Returns the cosine of $radians.
tan_val
my $result = tan_val($radians);
Returns the tangent of $radians.
asin_val
my $result = asin_val($x);
Returns the arc sine (inverse sine) of $x in radians. Croaks if $x is not in the range [-1, 1].
acos_val
my $result = acos_val($x);
Returns the arc cosine (inverse cosine) of $x in radians. Croaks if $x is not in the range [-1, 1].
atan_val
my $result = atan_val($x);
Returns the arc tangent (inverse tangent) of $x in radians.
atan2_val
my $result = atan2_val($y, $x);
Returns the arc tangent of $y/$x in radians, using the signs of both arguments to determine the quadrant of the result.
deg_to_rad
my $radians = deg_to_rad($degrees);
Converts degrees to radians.
rad_to_deg
my $degrees = rad_to_deg($radians);
Converts radians to degrees.
hypot_val
my $result = hypot_val($a, $b);
Returns the hypotenuse of a right triangle with sides $a and $b (i.e., sqrt($a*$a + $b*$b)).
normalize_angle
my $result = normalize_angle($radians);
Normalizes an angle to the range [-PI, PI].
sec_val
my $result = sec_val($radians);
Returns the secant of $radians (i.e., 1/cos($radians)).
csc_val
my $result = csc_val($radians);
Returns the cosecant of $radians (i.e., 1/sin($radians)).
cot_val
my $result = cot_val($radians);
Returns the cotangent of $radians (i.e., cos($radians)/sin($radians)).
is_valid_asin_arg
my $bool = is_valid_asin_arg($x);
Returns true if $x is a valid argument for asin_val() or acos_val() (i.e., in the range [-1, 1]).
SEE ALSO
Acme::ExtUtils::XSOne::Test::Calculator, Acme::ExtUtils::XSOne::Test::Calculator::Basic, Acme::ExtUtils::XSOne::Test::Calculator::Scientific, Acme::ExtUtils::XSOne::Test::Calculator::Memory