Is it possible to get the direction of the mouse (left, right, top and bottom) based on the last position and current position of the mouse? I wrote code to calculate the angle between two vectors, but I'm not sure if it is correct.
Can someone point me in the right direction?
public enum Direction { Left = 0, Right = 1, Down = 2, Up = 3 } private int lastX; private int lastY; private Direction direction; private void Form1_MouseDown(object sender, MouseEventArgs e) { lastX = eX; lastY = eY; } private void Form1_MouseMove(object sender, MouseEventArgs e) { double angle = GetAngleBetweenVectors(lastX, lastY, eX, eY); System.Diagnostics.Debug.WriteLine(angle.ToString());
c # position coordinates mouse direction
Ioannis
source share