本文介绍了快速斜边算法嵌入式处理器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有确定的角度的斜边一个聪明/高效的算法(即的sqrt(A²+称b²)),使用无硬件的嵌入式处理器上定点数学乘?

Is there a clever/efficient algorithm for determining the hypotenuse of an angle (i.e. sqrt(a² + b²)), using fixed point math on an embedded processor without hardware multiply?

推荐答案

除非你这样做是在> 1kHz时,在MCU甚至成倍没有硬件 MUL ISN Ť可怕。更糟糕的是多少开方。我会尝试修改我的应用程序,因此并不需要在所有的计算。

Unless you're doing this at >1kHz, multiply even on a MCU without hardware MUL isn't terrible. What's much worse is the sqrt. I would try to modify my application so it doesn't need to calculate it at all.

标准库很可能是最好的,如果你真的需要它,但你可以看看使用牛顿方法作为可能的选择。这将需要数乘法/除法周期不过来执行。

Standard libraries would probably be best if you actually need it, but you could look at using Newton's method as a possible alternative. It would require several multiply/divide cycles to perform, however.




  • AVR怪胎发布

  • Atmel App note AVR200: Multiply and Divide Routines (pdf)
  • This sqrt function on AVR Freaks forum
  • Another AVR Freaks post

这篇关于快速斜边算法嵌入式处理器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-13 01:23