嵌入式处理器的快速避免算法? [英] Fast Hypotenuse Algorithm for Embedded Processor?

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

问题描述

是否有一个聪明/有效的算法用于确定角度的斜边(即 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 并不可怕更糟的是 sqrt 。我会尝试修改我的应用程序,所以它根本不需要计算。

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.

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

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

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