How to detect whether mouse is moving in clockwise or anticlockwise direction just through mouse movement or mouse dragging???
-
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)
} -
@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 involveatan2()
:) -
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. -
@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? -
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.
-
@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....
-
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-javascriptAnd one more from other site:
https://gamedev.stackexchange.com/questions/22133/how-to-detect-if-object-is-moving-in-clockwise-or-counterclockwise-direction -
@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.
-
Ok I will wait for someone who can actually come up with the desired solution.
-
Why did you delete all your posts here?
-
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.