RE: Converting the sunrise module to use DateTime-util-calc
Hi Daisuke, Daisuke Maki wrote: > I'm fairly sure this is ok, but as I did it in such a hurry, can you > just download this and double check for me before I upload it to CPAN? > >http://www.wafu.ne.jp/~daisuke/DateTime-Util-Calc-0.03.tar.gz > Wait!!! I was going to ask you to add some functions to this module. like: sub atan2d { ( $RADEG * atan2( $_[0], $_[1] ) ); } sub revolution { # # # FUNCTIONAL SEQUENCE for revolution # # _GIVEN # any angle # # _THEN # # reduces any angle to within the first revolution # by subtracting or adding even multiples of 360.0 # # # _RETURN # # the value of the input is >= 0.0 and < 360.0 # my $x = $_[0]; return ( $x - 360.0 * floor( $x * $INV360 ) ); } sub rev180 { # # # FUNCTIONAL SEQUENCE for rev180 # # _GIVEN # # any angle # # _THEN # # Reduce input to within +180..+180 degrees # # # _RETURN # # angle that was reduced # my ($x) = @_; return ( $x - 360.0 * floor( $x * $INV360 + 0.5 ) ); } The names can be whatever you like (as long as I know what they are). I will download and test and let you know > BTW, DT::U::Calc uses Math::BigFloat's, which are > significantly slower > than just straight forward calculation. is that okay with you? As long as it works :) Ron Hill > > Daisuke Maki wrote: > >> >> That would be because I'm stupid and blindly copied sin_deg(), >> cos_deg() to asin_deg() and acos_deg(). >> >> Fix coming... >> >> --d
Re: Converting the sunrise module to use DateTime-util-calc
That would be because I'm stupid and blindly copied sin_deg(), cos_deg() to asin_deg() and acos_deg(). Fix coming... --d Hill, Ronald wrote: Hi All, I am in the process of converting the DateTime-Event-Sunrise module to use the DateTime-util-calc module. The problem I am having is using the acos_deg function in the cals module does not product the same results as my acosd function. Can someone tell me how I can get these 2 functions to agree? Am I doing something wrong? the output is: F:\scripts>me.pl t using my method: 76.1440743101727 t using util method: 1.56661657821494 F:\scripts> Here is a test script to demonstrate the problem. use strict; use warnings; use Math::Trig; use DateTime::Util::Calc qw(acos_deg); my $RADEG = ( 180 / pi ); my $cost = 0.239481255754665; my $t = acosd($cost); my $z = acos_deg($cost); print "t using my method: $t\n"; print "t using util method: $z\n"; sub acosd { ( $RADEG * acos( $_[0] ) ); } __END__ from Pauls c code whis is what I use in my module #define RADEG ( 180.0 / PI ) #define DEGRAD( PI / 180.0 ) /* The trigonometric functions in degrees */ #define sind(x) sin((x)*DEGRAD) #define cosd(x) cos((x)*DEGRAD) #define tand(x) tan((x)*DEGRAD) #define atand(x)(RADEG*atan(x)) #define asind(x)(RADEG*asin(x)) #define acosd(x)(RADEG*acos(x)) #define atan2d(y,x) (RADEG*atan2(y,x)) Thanks Ron Hill