Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to detect whether mouse is moving in clockwise or anticlockwise direction just through mouse movement or mouse dragging???
Forum Updated to NodeBB v4.3 + New Features

How to detect whether mouse is moving in clockwise or anticlockwise direction just through mouse movement or mouse dragging???

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 3 Posters 970 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BerahamKaatil
    wrote on last edited by
    #1

    I am able to rotate a medical image individually one by one i.e by commenting the clockwise rotation code it is getting rotated anticlockwise and by commenting the anticlockwise code it is getting rotated clockwise, this much able to achieve, here there is no issue, able to do it.
    But now I want it to function like:- Uncommenting both clockwise and anticlockwise codes simultaneously, image should get rotated to clockwise direction if my mouse is moving in clockwise direction and in anticlockwise if my mouse is moving in anticlockwise direction.
    I am trying to achieve it using if-else like:-
    If (Some condition or equation)
    {
    Image rotation code Anticlockwise(I have this code already)
    }

    else
    {
    Image rotation code Clockwise(I have this code also)
    }

    JonBJ 1 Reply Last reply
    0
    • B BerahamKaatil

      I am able to rotate a medical image individually one by one i.e by commenting the clockwise rotation code it is getting rotated anticlockwise and by commenting the anticlockwise code it is getting rotated clockwise, this much able to achieve, here there is no issue, able to do it.
      But now I want it to function like:- Uncommenting both clockwise and anticlockwise codes simultaneously, image should get rotated to clockwise direction if my mouse is moving in clockwise direction and in anticlockwise if my mouse is moving in anticlockwise direction.
      I am trying to achieve it using if-else like:-
      If (Some condition or equation)
      {
      Image rotation code Anticlockwise(I have this code already)
      }

      else
      {
      Image rotation code Clockwise(I have this code also)
      }

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @BerahamKaatil
      So for this I would Google, say, detect mouse clockwise motion. I have not looked through them, but there are several hits for this (try the stackoverflow ones). I won't attempt to guess which one is easiest, but it seems to involve atan2() :)

      1 Reply Last reply
      0
      • B Offline
        B Offline
        BerahamKaatil
        wrote on last edited by
        #3

        I have already tried those stack overflow solutions, but they seem to be of no use.
        As they are giving condition true and takes me into the for loop only for anticlockwise direction.
        But what I want is that the movement of my image changes when the direction of my mouse changes and the flow of the statement should enter into else-condition and hence rotate the image into clockwise direction as desired.

        JonBJ 1 Reply Last reply
        0
        • B BerahamKaatil

          I have already tried those stack overflow solutions, but they seem to be of no use.
          As they are giving condition true and takes me into the for loop only for anticlockwise direction.
          But what I want is that the movement of my image changes when the direction of my mouse changes and the flow of the statement should enter into else-condition and hence rotate the image into clockwise direction as desired.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @BerahamKaatil said in How to detect whether mouse is moving in clockwise or anticlockwise direction just through mouse movement or mouse dragging???:

          I have already tried those stack overflow solutions, but they seem to be of no use.
          As they are giving condition true and takes me into the for loop only for anticlockwise direction.

          Then you have done something wrong, as they clearly do determine clockwise vs anticlockwise, since that is the question they are answering. They cannot return true all the time, else they would be pointless.

          But what I want is that the movement of my image changes when the direction of my mouse changes and the flow of the statement should enter into else-condition and hence rotate the image into clockwise direction as desired.

          That is just testing the result of clockwise vs anticlockwise as a boolean for your if. You asked for "Some condition or equation", and that is what the posts give you. What else is there to say about this?

          1 Reply Last reply
          0
          • B Offline
            B Offline
            BerahamKaatil
            wrote on last edited by
            #5

            My dear friend this is what I am trying to say that it is returning the bool 1 everytime and then entering into the if-condition only as this 'if' gives 1 for anticlockwise direction my image is getting rotated only in anticlockwise direction only even when I am dragging my mouse in clockwise direction.

            So anyone with some new solution is welcomed or even someone who can improve the already present solution the stack overflow.

            JonBJ 1 Reply Last reply
            0
            • B BerahamKaatil

              My dear friend this is what I am trying to say that it is returning the bool 1 everytime and then entering into the if-condition only as this 'if' gives 1 for anticlockwise direction my image is getting rotated only in anticlockwise direction only even when I am dragging my mouse in clockwise direction.

              So anyone with some new solution is welcomed or even someone who can improve the already present solution the stack overflow.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @BerahamKaatil
              You have not even said which stackoverflow post you are trying, or how many of the offered ones you have tried, and how they all give the wrong result.... Do you really think they are all wrong and your code is right? For example, can you explain how the answer in https://stackoverflow.com/a/38029378/489865 has got its math wrong?

              Good luck finding someone here who will write you code when you claim all the existing ones don't work....

              1 Reply Last reply
              0
              • B Offline
                B Offline
                BerahamKaatil
                wrote on last edited by
                #7

                These are the solutions I tried from the stack overflow:
                1.https://stackoverflow.com/questions/14066933/direct-way-of-computing-clockwise-angle-between-2-vectors
                2.https://stackoverflow.com/questions/7586063/how-to-calculate-the-angle-between-a-line-and-the-horizontal-axis
                3.https://stackoverflow.com/questions/24294452/detect-mouse-direction-javascript

                And one more from other site:
                https://gamedev.stackexchange.com/questions/22133/how-to-detect-if-object-is-moving-in-clockwise-or-counterclockwise-direction

                JonBJ 1 Reply Last reply
                0
                • B BerahamKaatil

                  These are the solutions I tried from the stack overflow:
                  1.https://stackoverflow.com/questions/14066933/direct-way-of-computing-clockwise-angle-between-2-vectors
                  2.https://stackoverflow.com/questions/7586063/how-to-calculate-the-angle-between-a-line-and-the-horizontal-axis
                  3.https://stackoverflow.com/questions/24294452/detect-mouse-direction-javascript

                  And one more from other site:
                  https://gamedev.stackexchange.com/questions/22133/how-to-detect-if-object-is-moving-in-clockwise-or-counterclockwise-direction

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by
                  #8

                  @BerahamKaatil
                  And all 4 of them are wrong, and they all return anticlockwise (or clockwise) every time, right? And nobody has commented on this on stackoverflow against any of them.

                  Anyway, as I say, good luck finding someone else here who will know why they are all wrong and how to do it correctly for you. I won't comment any further so you can await the desired response here.

                  1 Reply Last reply
                  0
                  • B Offline
                    B Offline
                    BerahamKaatil
                    wrote on last edited by BerahamKaatil
                    #9

                    Ok I will wait for someone who can actually come up with the desired solution.

                    1 Reply Last reply
                    0
                    • jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Why did you delete all your posts here?

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • B Offline
                        B Offline
                        BerahamKaatil
                        wrote on last edited by
                        #11

                        Because I want answers and not quarreling my friend.
                        But I have restored them, so you can have a look and suggest me some solution.

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved