Q:

Using atan2 to rotate an image when dragged with the mouse

I'm working on a skeletal animation editor. Right now, each bone has a start and end point, when the mouse is under a point,subsequent dragging will cause the bone to rotate based on where the mouse is. To do this, I call atan2 and transform the mouse coordinates to local space where the local is where the mouse was pressed. Although this "works", it feels really wrong. The vector formed by the bone is not necessarily parallel to the mouse point, which it should be.
I feel like there is something about atan2 that I do not understand.
:
    if(boneUnderMouse)
    {
        boneUnderMouse->setAngle(startAngle + 
       (atan2((float)event.mouse.x - startX,event.mouse.y   - startY)));
    }

Thanks

A:

atan2 has order of arguments y, x. Thus you need
 atan2((float)event.mouse.y - startY, (float)event.mouse.x - startX)

