Move your mouse pointer around and watch what the arrow does.
All code by @ITeachMathInClass. Scroll down for a mathematical explanation of the code. I used Trigonometric functions to calculate in this project. To find the angle of the hypotenuse of a right triangle given the adjacent (x) and the opposite (y) sides, I used the atan function. This function is the reverse function of the tan function, which is what finds the length of the hypotenuse of a right triangle based on its angle and its opposite and adjacent sides. The formula used for tan is x/y, so the formula used for atan is y/x. This project takes the atan of the length of the hypotenuse of a right triangle which is calculated based on x and y of the mouse pointer, which gives the angle that the arrow points at. There is a bit of a coding trick to configure a full 360 degree rotation, which you can ask about in the comments or see inside the project for.