Calculate atan2 without std functions or C99

前端 未结 4 1800
遥遥无期
遥遥无期 2021-01-03 06:09

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

4条回答
  •  清歌不尽
    2021-01-03 06:35

    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.

提交回复
热议问题