It is necessary that the picture would turn in the direction of the mouse. The angle is calculated so -

m.RotateAt( (float) (Math.Atan2(MousVect.X -14, MousVect.Y ) * (180 / Math.PI))+ 90,new Point(601,578) ); Gr.Transform = m; Gr.DrawImage(car, new Point(600-17,600-40)); 

Where MousVect X, Y - values ​​of the vector with the beginning in the middle of the picture and the end in the current coordinates of the mouse. The image vector is always 14.0. The problem is that in the interval of 0 - 180 degrees and 0 - (-180) degrees, the picture is directed in the opposite direction from the mouse. Where did I make a mistake?

    1 answer 1

    Arguments atan2 go in order (y, x), and you have the opposite
    (You are trying to compensate for this by adding 90 degrees)

    • Corrected, but the picture unfolds in the opposite direction of the arrow in the direction of the arrow. PS Compensated for this by adding 180 degrees, now everything is perfect. Thank. - Alexey
    • @Alexey: You just had to add - to the value. - LLENN
    • @LLENN No, when - was displayed incorrectly. Put it was the first thing I tried - Alexey
    • minus the angle value is a reflection about the OX axis, and you needed a reflection about the center of coordinates, it really corresponds to +180 degrees, you can also change the signs of both arguments atan2 - MBo