murphy@pur-phy (William J. Murphy) (02/20/89)
I posted sometime last week about taking the sources for atan2 and j0, j1, y0, y1 from our local Unix box for use with Manx 3.6 c. Well, I was informed that I need to clarify that they were from 4.3BSD Unix and NOT from AT&T derivitives. As I now understand it, A user may not take sources of any kind from AT&T copyrighted materials. Sorry for the confusion. Bill Murphy
ecphssrw@afws.csun.edu (Stephen Walton) (02/24/89)
This took about ten minutes, counting testing. Based on the manual
entry for Microsoft C's atan2 (which is all I had around), but the
code itself is entirely PD (in fact, I just wrote and tested it
against the system atan2()).
/* myatan2 */
#include <errno.h>
#include <stdio.h>
#include <math.h>
#define PI 3.14159265359
extern int errno;
double myatan2(y, x)
double y, x; {
double atan();
if (x == 0.0) {
if (y == 0.0) {
errno = EDOM;
fputs("atan2: DOMAIN error\n", stderr);
return(0.0);
} else if (y > 0.0)
return(PI/2.0);
else
return(-PI/2.0);
} else if (x > 0)
return(atan(y/x));
else
if (y >= 0.0)
return(atan(y/x) + PI);
else
return(atan(y/x) - PI);
}