Results 1 to 17 of 17

Thread: Test This Algorithm

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Sedgefield
    Posts
    337

    Question Test This Algorithm

    Here is a test that moves between controls on ALT+ARROW_KEY. Mathematically, it moves correctly to the nearest control in a particular direction, however I think it intuitively feels wrong.
    (i.e. it doesn't move where you think it should).

    Anyone want to try and make it 'feel' better?
    Attached Files Attached Files

    Dan

    Outside of a dog, a book is a man's best friend.
    Inside of a dog, it's too dark to read.

  2. #2
    Hyperactive Member DavidHooper's Avatar
    Join Date
    Apr 2001
    Posts
    357
    Would you compile it for me please? I'd try it, but my copy of VB is on a different computer...

    (You'll prolly have to zip it once compiled so you can upload it.)
    There are 10 types of people in the world - those that understand binary, and those that don't.

  3. #3
    Fanatic Member JPicasso's Avatar
    Join Date
    Aug 2001
    Location
    Kalamazoo, MI
    Posts
    843
    Not many people WANT an exe to test.


    anyway, ya, don't feel right.

    UP and DOWN are fine,

    left and right are, first of all, reversed, and second of all,
    just... wrong. like you said, you see what the reason is,
    but we need a new reason. I don't know what that would
    be aside from checking the alt+direction on each text box events.
    Merry Christmas

  4. #4
    Hyperactive Member DavidHooper's Avatar
    Join Date
    Apr 2001
    Posts
    357
    I trust Judd...
    There are 10 types of people in the world - those that understand binary, and those that don't.

  5. #5
    Addicted Member Martin Wilson's Avatar
    Join Date
    Mar 2002
    Location
    :)
    Posts
    236
    I think it is because you are taking the left values of the text boxes and not considering the width, when moving right:

    Text12 is obviously the closest to text11, but when just considering the top-left corner text13 is the nearest.
    Attached Images Attached Images  
    What is the answer to this question?

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Sedgefield
    Posts
    337

    Cool OK...

    A new zip with exe for David (with L-R reversal fixed).

    I think Martin is at least partly correct - I probably need to calculate distances from the centrepoint of each control.

    I'm also wondering whether left and right should be more like a previous/next functionality (i.e. from top left to bottom right, cycling through the controls).

    THis is all actually to get around a tab-ordering problem in a C++ GUI with a 'designable' interface. Another alternative would be some way to easily set the tab order of controls (a la Developer Studio). Currently we have to use Z-ordering and its a royal pain....
    Attached Files Attached Files

    Dan

    Outside of a dog, a book is a man's best friend.
    Inside of a dog, it's too dark to read.

  7. #7
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    There's always the distance formula.


  8. #8
    Hyperactive Member DavidHooper's Avatar
    Join Date
    Apr 2001
    Posts
    357
    Hi judd,

    If, say, I choose left then I think the proggie should give more 'priority' to controls on the left, and possibly further away vertically.
    So for instance, going left from Text6 should move to Text8 and not Text7.

    Possible?
    There are 10 types of people in the world - those that understand binary, and those that don't.

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Sedgefield
    Posts
    337

    Lightbulb

    Hi David,

    Good idea...looking at the code shows that I went for the simplest option to begin with - literally everything to the left is considered 'left'.

    I could possibly calculate the proper direction vector from 0 - 360, but split the quadrant diagnally, like this:

    Code:
    \           |           /
     \          |          / 
      \        U|P        /  
       \        |        /   
        \       |       /    
         \      |      /     
          \     |     /      
           \    |    /       
            \   |   /        
             \  |  /         
              \ | /          
      LEFT     \|/    RIGHT  
    -------------------------
               /|\           
              / | \          
             /  |  \         
            /   |   \        
           /    |    \       
          /     |     \      
         /      |      \     
        /     DO|WN     \    
       /        |        \   
      /         |         \  
     /          |          \ 
    /           |           \

    Think that would be more logical?

    Dan

    Outside of a dog, a book is a man's best friend.
    Inside of a dog, it's too dark to read.

  10. #10
    Hyperactive Member DavidHooper's Avatar
    Join Date
    Apr 2001
    Posts
    357
    Yes that would work better. Basically, you'resaying that you would give priority to moving to a more distant but more 'left' textbox than a closer but less 'left' one. Sounds good.
    There are 10 types of people in the world - those that understand binary, and those that don't.

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Sedgefield
    Posts
    337

    Talking Update

    This one 'feels' prety good. Distance is worked out center to center, and my quadrant is split diagonally.

    PS...thanks to Guv for ArkTangent
    Attached Files Attached Files

    Dan

    Outside of a dog, a book is a man's best friend.
    Inside of a dog, it's too dark to read.

  12. #12
    Addicted Member Martin Wilson's Avatar
    Join Date
    Mar 2002
    Location
    :)
    Posts
    236
    Text12 goes to text1 and not text10, that just feels even more wrong than before, and text14 to text1 instead of text16.
    What is the answer to this question?

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Sedgefield
    Posts
    337

    Suggestions....?

    You think its worse Martin?

    Any suggestions? I can only think of using different rules for different areas.....but that gets v complex...

    Dan

    Outside of a dog, a book is a man's best friend.
    Inside of a dog, it's too dark to read.

  14. #14
    Addicted Member Martin Wilson's Avatar
    Join Date
    Mar 2002
    Location
    :)
    Posts
    236
    Some parts of it are better...some are worse though. I think you need to find the angle and the distance and somehow weight them. So the one with the most 'leftnest' (smallest angle) and the closest is the one picked. Give distance and angle different priorities. You'll work it out somehow...I may give it a go if I can be bothered...very busy atm though.
    What is the answer to this question?

  15. #15
    Addicted Member Martin Wilson's Avatar
    Join Date
    Mar 2002
    Location
    :)
    Posts
    236
    Just thinking...you could work out the absolute angle from the ideal and add it to the distance and the one with the smallest values wins...it might need some tweaking though.
    What is the answer to this question?

  16. #16
    Hyperactive Member DavidHooper's Avatar
    Join Date
    Apr 2001
    Posts
    357
    ^ agrees with Martin.
    There are 10 types of people in the world - those that understand binary, and those that don't.

  17. #17

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Sedgefield
    Posts
    337

    Relating to this...

    I want to randomly distribute the text boxes on my form (easy enough), but I don't want any of them to overlap?

    Any built in VB way of checking this, or do I have to do it manually?

    Dan

    Outside of a dog, a book is a man's best friend.
    Inside of a dog, it's too dark to read.

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