Bill2
()
Thu Sep 05 2002 01:22 PM
Re:Distance function sqrt(a*a+b*b [+c*c...])

>Given two or three numbers, byte or int16, what
>is the best way to compute the "distance"
>function (square root of the sum of squares)?
>Certainly computing the square root of the sum of 
>squares is possible, but it seems needlessly 
>expensive in terms of CPU time.  Can anyone offer 
>a better algorithm for the PIC16x?

I can't offer a better algorithm, but I can
point you to a square root routine I used
when I need to take a square root of a 16-bit
integer as fast as possible.

It's in assembly, but can be "inlined" into C
code (what I did).

http://www.dattalo.com/technical/software/pic/picsqrt.html

Bill



Contact Us | Privacy statement HI-TECH Software

Powered by UBB.threads™ 6.5.5