Main Content

atan2

计算四象限反正切

自 R2020a 起

库:
Motor Control Blockset / Controls / Math Transforms
Motor Control Blockset HDL Support / Controls / Math Transforms

描述

atan2 模块对两个实数执行四象限反正切运算。

方程

此方程描述该模块如何计算四象限反正切值 (θ)。

Theta=atan2(A,B)={arctan(AB)                 if B>0,arctan(AB)+π           if B<0 and A0,arctan(AB)π           if B<0 and A<0,+π2                            if B=0 and A>0, π2                            if B=0 and A<0,undefined                 if B=0 and A=0.

其中:

π<Thetaπ    (Radians)

端口

输入

全部展开

作为模块的输入提供的 y 轴上的实数。

数据类型: single | double | fixed point

作为模块的输入提供的 x 轴上的实数。

数据类型: single | double | fixed point

输出

全部展开

反正切表示的角度。这是一个从原点到指定点 (x,y) 的矢量与正 x 轴所形成的夹角。

数据类型: single | double | fixed point

下图显示了输入值 A、B 和反正切在 x-y 坐标平面上的表示。

参数

全部展开

模块用于 atan2 计算的逼近类型:

  • None - 模块不使用任何逼近。

  • CORDIC - 模块使用基于坐标旋转数字计算 (CORDIC) 算法的逼近。

  • Lookup - 模块使用基于查找表的逼近。

注意

使用模块生成代码时:

  • None 选项更适合单精度数据类型。

  • CORDIC 选项更适合 FPGA 部署。

  • Lookup 选项更适合定点数据类型。

输出值的单位。

扩展功能

C/C++ 代码生成
使用 Simulink® Coder™ 生成 C 代码和 C++ 代码。

定点转换
使用 Fixed-Point Designer™ 设计和仿真定点系统。

版本历史记录

在 R2020a 中推出