I’d like to replicate the rotation tool in the editor in-game and can’t seem to derive how the 2D mouse motions are mapped to positive & negative rotations. Depending on the orientation of the object there seems to be a direction where you can drag the mouse and have no rotation and, perpendicular to that, a direction that maximizes the rotation (see attached gifs).

Could some one help me understand how the mapping of 2D mouse motion to positive/negative rotation happens?

EDIT: I believe the directions are the tangent line at the point clicked and the radial projected into screen space?

Looks like it takes the angle from origin to mouse in that plane of rotation, then observes changes in that angle and applies them.

I did that in the enclosed package with 2D rotation… see the second (righthand) one.

Relevant codelet:

```
void PerformCircularRotation()
{
// where is our center on screen?
Vector3 center = Camera.main.WorldToScreenPoint(transform.position);
// angle to previous finger
float anglePrevious = Mathf.Atan2(center.x - lastPosition.x, lastPosition.y - center.y);
Vector3 currPosition = Input.mousePosition;
// angle to current finger
float angleNow = Mathf.Atan2(center.x - currPosition.x, currPosition.y - center.y);
lastPosition = currPosition;
// how different are those angles?
float angleDelta = angleNow - anglePrevious;
// rotate by that much
transform.Rotate(new Vector3(0, 0, angleDelta * Mathf.Rad2Deg));
}
```

6201992–680924–RotateZViaDrag.unitypackage (20 KB)