DSPRelated.com
Forums

Fast integer distance formula

Started by Robert Scott October 4, 2006
On Wed, 04 Oct 2006 16:04:49 GMT, ---@--- (Robert Scott) wrote:

>I have an approximation for the Pythagorean distance formula (magnitude of >vector [x,y]) using integer arithmetic that I would like to improve. Currently >I am using this: >
(snipped)
> >The improvement I am looking for is in accuracy. I would like to try for a >4-fold improvement in accuracy (.5%) without substantially increasing the >running time of what I have now. Does anyone know of a better approximation >that is almost as fast? > >Robert Scott >Ypsilanti, Michigan
Hi Robert, 0.5% max error is a tough goal to achieve. (I don't speak "C", so I'm not able understand your code.) Have ya' had a look at: "A Root of Less Evil", IEEE Signal Processing Magazine, DSP Tips & Tricks column, Vol. 22, No. 2, March 2005. There's a scheme in that article that yields 1% max error in magnitude approximation. Good Luck, [-Rick-] Ypsilanti, huh? Have they fixed the roads in Michigan yet?