Prev Next

AD Two Argument Inverse Tangent Function

Syntax
theta = atan2(yx)

Purpose
Determines an angle  \theta \in [ - \pi , + \pi ] such that  \[
\begin{array}{rcl}
     \sin ( \theta )  & = & y / \sqrt{ x^2 + y^2 }  \\
     \cos ( \theta )  & = & x / \sqrt{ x^2 + y^2 }
\end{array}
\] 


Base
A definition of atan2, for the case where both arguments are float or both arguments are double, is included in the CppAD namespace (the corresponding results has the same type as the arguments). The type Base can be any type in the AD levels above above float or double.

y
The argument y has one of the following prototypes
     const AD<
Base>               &y
     const VecAD<
Base>::reference &y

x
The argument x has one of the following prototypes
     const AD<
Base>               &x
     const VecAD<
Base>::reference &x

theta
The result theta has prototype
     AD<
Basetheta

Operation Sequence
The AD of Base operation sequence used to calculate theta is independent of x and y.

Example
The file Atan2.cpp contains an example and test of this function. It returns true if it succeeds and false otherwise.
Input File: cppad/local/atan2.hpp