Category : Science and Education
Archive   : AA-51.ZIP
Filename : ZATAN2.C

 
Output of file : ZATAN2.C contained in archive : AA-51.ZIP
/* atan2()
*
* Quadrant correct inverse circular tangent
*
*
*
* SYNOPSIS:
*
* double x, y, z, atan2();
*
* z = atan2( x, y );
*
*
*
* DESCRIPTION:
*
* Returns radian angle between 0 and +2pi whose tangent
* is y/x.
*
*
*
* ACCURACY:
*
* See atan.c.
*
*/


/*
Cephes Math Library Release 2.0: April, 1987
Copyright 1984, 1987 by Stephen L. Moshier
Direct inquiries to 30 Frost Street, Cambridge, MA 02140
Certain routines from the Library, including this one, may
be used and distributed freely provided this notice is retained
and source code is included with all distributions.
*/


extern double PI;

double zatan2( x, y )
double x, y;
{
double z, w;
short code;
double atan();


code = 0;

if( x < 0.0 )
code = 2;
if( y < 0.0 )
code |= 1;

if( x == 0.0 )
{
if( code & 1 )
return( 1.5*PI );
if( y == 0.0 )
return( 0.0 );
return( 0.5*PI );
}

if( y == 0.0 )
{
if( code & 2 )
return( PI );
return( 0.0 );
}


switch( code )
{
case 0: w = 0.0; break;
case 1: w = 2.0 * PI; break;
case 2:
case 3: w = PI; break;
}

z = atan( y/x );

return( w + z );
}


  3 Responses to “Category : Science and Education
Archive   : AA-51.ZIP
Filename : ZATAN2.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/