PDA

Click to See Complete Forum and Search --> : Length of Diag in Grid?


The Hobo
Sep 24th, 2004, 08:18 AM
Is there an easy method for finding the length of a diagnol line in a grid. Say, if I have:


x x x x x x x x x x
x x x x x x x x x x
x x x x x x x x x x
x x x x x x x x x x
x x x x x x x x x x
x x x x x x x x x x


And I know that x is 6 and y is 4 (bottom x). How could I find the length of any diagnol line, no matter where it starts?

alkatran
Sep 24th, 2004, 08:53 AM
a^2 + b^2 = c^2

Or...

Length = sqr(xdif^2 + ydif^2)

opus
Sep 25th, 2004, 07:13 AM
Or are you talking about the number of X's in a diagonal line in your grid?

Max (XDiff; YDiff)

Onlyalid if lines are either horizontal, vertical or at a 45 degree to that.

Darkwraith
Sep 25th, 2004, 06:26 PM
Are your lines composed of X's or are they composed of the endpoints of the line?

The Hobo
Sep 25th, 2004, 09:25 PM
They're composed of X's. It's for a crossword puzzle, so I was trying to figure out how many letters could be in that line of spots.

But...I figured out my teacher wants us to do this a different way, so I don't really need to know anymore. :(

Darkwraith
Sep 27th, 2004, 11:12 AM
So is this resolved then?

The Hobo
Sep 27th, 2004, 12:35 PM
Originally posted by Darkwraith
So is this resolved then?

Yes and no. I don't need the answer anymore, but I'm still curious about how it can be accomplished.

opus
Sep 29th, 2004, 12:19 AM
If it's for a crossword, you're counting the "x" or the letters.
So use the max(XDiff,YDiff), or more precise max(Xdiff+1;YDiff+1).