Subj : Re: Rational Trig To : comp.programming From : William Date : Mon Sep 19 2005 10:59 am "Gerry Quinn" wrote in message news:MPG.1d98a318c2ec716d98a5bb@news.indigo.ie... > In article , > Reply@NewsGroup.Please says... > > > > In fact, just a few days ago someone was asking about efficient > > ways to find the closest points between two arrays of 3D points. > > A number of proposed solutions involved square roots when > > there is no reason to take a square root at all. (Squared > > distances compare just as easily as the distances themselves.) > > True, but anyone who ever wrote a computer game is already wise to that > trick! You'd be surprised. At one company I was handed some "closest color" code and asked to see if I could optimize it. The lead programmer thought it was pretty good and I'd have to convert it to assembly to improve it. I just pulled out the square roots. (That, and a couple of other "obvious" tricks made it 18 times faster.) > Whatever the format, it should simplify to the same equations in > principle. (Of course this does not always happen in practice.) The "simplest" equation isn't always the most efficient, though, for some values of "simplest." My point was that alternative representations can give you insights you might not get otherwise. -Wm .