Skip to Main Content Skip to Search
Product Documentation

cordicatan2 - CORDIC-based four quadrant inverse tangent

Syntax

theta = cordicatan2(y,x)
theta = cordicatan2(y,x,niters)

Description

theta = cordicatan2(y,x) computes the four quadrant arctangent of y and x using a CORDIC algorithm approximation.

theta = cordicatan2(y,x,niters) performs niters iterations of the algorithm.

Input Arguments

y,x

y,x are Cartesian coordinates. y and x must be the same size. If they are not the same size, at least one value must be a scalar value. Both y and x must have the same data type.

niters

niters is the number of iterations the CORDIC algorithm performs. This is an optional argument. When specified, niters must be a positive, integer-valued scalar. If you do not specify niters or if you specify a value that is too large, the algorithm uses a maximum value. For fixed-point operation, the maximum number of iterations is one less than the word length of y or x. For floating-point operation, the maximum value is 52 for double or 23 for single. Increasing the number of iterations can produce more accurate results but also increases the expense of the computation and adds latency.

Output Arguments

theta

theta is the arctangent value, which is in the range [-pi, pi] radians. If y and x are floating-point numbers, then theta has the same data type as y and x. Otherwise, theta is a fixed-point data type with the same word length as y and x and with a best-precision fraction length for the [-pi, pi] range.

Definitions

CORDIC

CORDIC is an acronym for COordinate Rotation DIgital Computer. The Givens rotation-based CORDIC algorithm is among one of the most hardware-efficient algorithms available because it requires only iterative shift-add operations (see [1], [2]) The CORDIC algorithm eliminates the need for explicit multipliers. Using CORDIC, you can calculate various functions, such as sine, cosine, arc sine, arc cosine, arc tangent, and vector magnitude. You can also use this algorithm for divide, square root, and hyperbolic, and logarithmic functions.

Increasing the number of CORDIC iterations can produce more accurate results, but doing so also increases the expense of the computation and adds latency.

Examples

Floating-point CORDIC arctangent calculation.

theta_cdat2_float = cordicatan2(0.5,-0.5)

theta_cdat2_float =
    2.3562
 

Fixed- point CORDIC arctangent calculation.

theta_cdat2_fixpt = cordicatan2(fi(0.5,1,16,15),fi(-0.5,1,16,15));

theta_cdat2_fixpt = 
    2.3562

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 16
        FractionLength: 13

References

[1] Volder, J.E. "The CORDIC Trigonometric Computing Technique," IRE Transactions on Electronic Computers. Vol. EC-8, September 1959, pp. 330–334.

[2] Andraka, R. "A survey of CORDIC algorithm for FPGA based computers." Proceedings of the 1998 ACM/SIGDA sixth international symposium on Field programmable gate arrays. Feb. 22–24, 1998, pp. 191–200.

See Also

atan2

  


Free Early Verification Kit

Learn how to apply early verification to your development process through these technical resources.

How much time do you spend on testing to ensure implementation meets system-level requirements?

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS