计算ATAN2没有性病的功能或C99 [英] Calculate atan2 without std functions or C99

查看:165
本文介绍了计算ATAN2没有性病的功能或C99的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我计算从3轴加速度计的角度,但我的编译器不具有ATAN ATAN2或功能。它有一个预留内存插槽,但它调用的功能,我不能在任何文件中找到。

我的编译器是Keil公司的μVision4运行ARMCC编译器。
该编译具有文件math.h中,但功能是extern和不存在


 的extern _ARMABI双ATAN2(双/ * Y * /双/ * X * /);


有一个lib或功能,我可以包括具有功能反正切实现的?
或者是有一个替代函数从加速度计计算的角度?我需要的角度完整的3轴校准。

编辑:我希望避免全部pre-计算值表


解决方案

它不是很难实现自己的 arctan2 。转换 arctan2 反正切使用的这个公式。而且,您可以然后使用此无穷级数计算反正切。如果你总结足够数量的这种无穷级数的条款,你会得到非常接近到什么库函数 arctan2 一样。

下面是种相似执行EXP() 了你可以作为参考使用。

I am calculating angles from a 3-axis accelerometer, but my compiler doesn't have a atan or atan2 function. It has a reserved memory slot, but it calls a function i can't find in any files.

My compiler is Keil µVision 4 running the ARMCC compiler. The compiles has the file math.h, but the function is extern and doesn't exist:

  extern _ARMABI double atan2(double /*y*/, double /*x*/);

Is there a lib or function I can include that has the function arctan implemented? Or is there an alternative function to calculate angles from accelerometer? I need full 3-axis calibration of the angles.

Edit: I was hoping to avoid a table full of pre-calculated values.

解决方案

Its not very difficult to implement your own arctan2. Convert arctan2 to arctan using this formula. And you can then calculate arctan using this infinite series. If you sum sufficient number of terms of this infinite series, you will get very close to what the library function arctan2 does.

Here is one similar implementation for exp() that you could use as a reference.

这篇关于计算ATAN2没有性病的功能或C99的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆