home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.fortran      Putting John Backus on a giant pedestal      5,127 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 4,767 of 5,127   
   Lawrence D'Oliveiro to All   
   Angle Units For Trig Functions   
   20 Oct 24 03:47:13   
   
   From: ldo@nz.invalid   
      
   I see that the Fortran 2023 spec has added a bunch of parallel trig   
   functions that work in degrees.   
      
   I find this sort of thing unnecessary. It seems conventional to add   
   functions for converting between degrees and radians, but a simpler way is   
   to simply define a conversion factor for each angle unit. One conversion   
   factor is simpler than two functions for each angle unit.   
      
   So trig functions always work in radians. Supposing we have   
      
       real, parameter :: DEG = PI / 180   
       real, parameter :: CIRCLE = 2 * PI   
       real, parameter :: RAD = 1   
      
   Then   
      
       sin(x) -- sin of x in radians   
       sin(x * DEG) -- x is in degrees   
       atan2(y, x) -- arctangent is in radians   
       atan2(y, x) / DEG -- arctangent is in degrees   
      
   and we can furthermore have equivalences like   
      
       sin(90 * DEG) = sin(0.25 * CIRCLE) = sin(PI / 2)   
      
   (to within rounding error, of course)   
      
   and it is easy enough to add other units, e.g.   
      
       real, parameter :: GRAD = PI / 200   
      
   Anybody remember those?   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca