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

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

问题描述

我正在从三轴加速度计计算角度,但是我的编译器没有atan或atan2功能。它有一个保留的内存插槽,但它调用了我找不到任何文件的功能。



我的编译器是KeilμVision4运行ARMCC编译器。
编译器具有文件math.h,但该函数是extern并且不存在:


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


有没有一个lib或函数我可以包括它的功能arctan执行?
还是有一个替代功能来计算加速度计的角度?我需要对角度进行全三轴校准。



编辑:我希望避免一个充满预计值的表。

解决方案

它不是很难实现你自己的 arctan2 。使用 arctan2 转换为 arctan 定义rel =nofollow noreferrer>这个公式。然后,您可以使用此无限制来计算 arctan 系列。如果您总计这个无限系列的足够数量的条款,您将非常接近图书馆功能 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.

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

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