View Single Post
  #6  
Old May 18th, 2009, 08:40 PM

Micah Micah is offline
Major
 
Join Date: Dec 2006
Posts: 1,226
Thanks: 12
Thanked 86 Times in 48 Posts
Micah is on a distinguished road
Default Re: Diagonal Distance/Range

I think the "if (dx>0...)" bits subtract 1 from the range for each of those pairs that are true, so for a diagonal line you'd get range-length 1, 3, 5, 6, 8, 10, 11, 13, 15, 16. For straighter lines you'd be using the shorter coordinate to pass through each of those if gates, so if you have a differential of x=20 y=5 you would add them to get 25 and then subtract one for the first and second if statements, for a total of 23. Hopefully that's clear, and correct.
Reply With Quote