[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]


atan2

Arctangent function.

Compatibility:

This function is compatible with the following targets:

ANSI

BeOS

EMB/RTOS

Mac OS

Palm OS

Win32


Prototype:
#include <math.h>

double atan2(double y, double x);
float atan2f(float, float);
long double atan2l(long double, long double);
Parameters:

Parameters for this function are:

y  
double, float or long double  
Value one  
x  
double, float or long double  
Value two  

Remarks:

This function computes the value of the tangent of x/y using the sines of both arguments. See "Example of acos(), asin(), atan(), atan2() usage." for example usage.

A domain error occurs if both x and y are zero.

Return:

The function atan2() returns the arc tangent of y/x in the range

[-, ++ radians.

See Also:

"Inlined Intrinsics Option"

"tan"

"errno"

Example of acos(), asin(), atan(), atan2() usage.:
#include <math.h>
#include <stdio.h>

int main(void)
{
	double x = 0.5, y = -1.0;
	
	printf("arccos (%f) = %f\n", x, acos(x));
	printf("arcsin (%f) = %f\n", x, asin(x));
	printf("arctan (%f) = %f\n", x, atan(x));
	printf("arctan (%f / %f) = %f\n", y, x, atan2(y, x));

	return 0;
}

Output:
arccos (0.500000) = 1.047198
arcsin (0.500000) = 0.523599
arctan (0.500000) = 0.463648
arctan (-1.000000 / 0.500000) = -1.107149


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: August 16, 2000