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?
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.
sqrt
function on AVR Freaks forum