Availability: |
| ||||||||

Property/method value type: | Number primitive | ||||||||

JavaScript syntax: | - | Math.atan2(, aValue1)aValue2 | |||||||

Argument list: | aValue1 | Some meaningful numeric value | |||||||

aValue2 | Some meaningful numeric value |

This function computes the quotient of arg2/arg1 and then returns the arc tangent of the result. It takes into account which quadrant the value falls into according to the signs of the two arguments.

It is provided in several languages other than JavaScript for those situations where very large numbers are involved.

Traditionally, for this function, the Y argument is placed first and the X argument second.

Special boundary conditions that affect the results are:

Argument1 | Argument2 | Result |
---|---|---|

+infinity | +infinity | +pi/4 |

+infinity | -infinity | +3pi/4 |

+infinity | non zero | +pi/2 |

-infinity | +infinity | -pi/4 |

-infinity | -infinity | -3pi/4 |

-infinity | non zero | -pi/2 |

0 | negative | pi * sign of Argument1 |

0 | positive | 0 |

< 0 | -infinity | -pi |

< 0 | 0 | -pi/2 |

> 0 | -infinity | +pi |

> 0 | 0 | +pi/2 |

Any value | NaN | NaN |

NaN | Any value | NaN |

non zero | +infinity | 0 |

The exact value yielded by this function may vary slightly from implementation to implementation due to differences in the underlying precision of the implementations math routines and the specific algorithm selected to evaluate this function.

The result of this method is the arc-tangent of the slope of the two arguments. The result is expressed in radians and ranges from -pi to +pi.

Prev | Home | Next |

Math.atan() | Up | Math.ceil() |

JavaScript Programmer's Reference, Cliff WoottonWrox Press (www.wrox.com)Join the Wrox JavaScript forum at p2p.wrox.comPlease report problems to support@wrox.com© 2001 Wrox Press. All Rights Reserved. Terms and conditions. |