Results 1 to 8 of 8

Thread: Length of Diag in Grid?

  1. #1

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Length of Diag in Grid?

    Is there an easy method for finding the length of a diagnol line in a grid. Say, if I have:

    Code:
    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?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  2. #2
    Fanatic Member alkatran's Avatar
    Join Date
    Apr 2002
    Location
    Canada
    Posts
    860
    a^2 + b^2 = c^2

    Or...

    Length = sqr(xdif^2 + ydif^2)
    Don't pay attention to this signature, it's contradictory.

  3. #3
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    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.
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  4. #4
    Fanatic Member
    Join Date
    Jan 2003
    Posts
    1,004
    Are your lines composed of X's or are they composed of the endpoints of the line?
    "Can't" and "shouldn't" are two totally separate things.

    All questions should be answered. All answers should be true. That is why I post.

  5. #5

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  6. #6
    Fanatic Member
    Join Date
    Jan 2003
    Posts
    1,004
    So is this resolved then?
    "Can't" and "shouldn't" are two totally separate things.

    All questions should be answered. All answers should be true. That is why I post.

  7. #7

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  8. #8
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    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).
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width