On Thu, Jul 11, 2002 at 10:52:31AM -0700, John Porter wrote: > > Dan Sugalski wrote: > > Nicholas Clark: > > > Unless I'm being thick, x" < y" whenever x < y for positive x > > > and y (ie you don't need to take the square root of the > > > hypotenuse to work out which hypotenuse is shorter. And all > > > we're actually interested in which one is shorter, aren't we?) > > > > We can also be dumb and just compare a^2+b^2. > > Yes, that's exactly what Nick was saying.
Wasn't that was Dan was saying? :-) [given his choice of words] <ducks> On Thu, Jul 11, 2002 at 02:39:17PM -0400, Andy Dougherty wrote: > On Wed, 10 Jul 2002, Nicholas Clark wrote: > > > > Dan Sugalski wrote: > > > > > > Heh. I never expected to have to dust off my trig skills when I > > > > started this. If I need to dig out the calculus books, I think I'll > > > > just go run screaming... > > > > Unless I'm being thick, x² < y² whenever x < y for positive x and y > > (ie you don't need to take the square root of the hypotenuse to work out which > > hypotenuse is shorter. And all we're actually interested in which one is > > shorter, aren't we?) > > (Assuming, of course, that |x| and |y| are both >= 1, which is obviously > true here since they are integers. (That's the sort of trick they like to > put in the SAT math section.)) I think that I will count myself as stupid then. I was thinking x, y both > 0, as I was aware -1 > -2, but (-1)² < (-2)², but I did suspect that I'd missed something else. (be careful - I don't think you meant to have the modulus of x or y) > Assuming x and y are coordinates in a 2-d space, and that both are > integers >= 0, why not just use what is affectionately called the > "taxicab" metric: x+y? It is just as "valid" and even quicker to > compute than the Euclidean metric sqrt(x^2 + y^2). I was thinking that the metric (x*x + y*y) would be fast to calculate, as that's all we need for ordering. (or x*x + y*y* + z*z or however many dimensions you happen to need) And I live in London, where we don't have a regular grid of streets, so our taxis don't do what yours do. :-) [And even if your taxis don't drive on a grid either, I suspect that they don't drive on the left side of the road. And I'd hate to think what metric they use, but it goes up after midnight and in the vicinity of Heathrow Airport. I don't think we would want parrot method dispatch to do that] > Of course the ordering of which is "closer" is different depending on the > metric chosen -- which is partly my point. If the actual result obtained > from a calculation would differ in any significant way depending on which > metric were used, then it might be a warning sign that there's a > higher-level problem at hand. > > Practically, of course, any metric is fine for the moment -- it can always > be changed later if warranted. These are both good points I'd not thought of. Nicholas Clark -- Even better than the real thing: http://nms-cgi.sourceforge.net/