# Move an object in a circular path according to touch position

I am trying to move my object in this circular path with touch .
I am trying to calculate first the angle between origin and touchpos , (all of my code in touchphase.moved block)

``````Vector3 touchPos = Camera.main.ScreenToWorldPoint (touch.position);
float angle = (Mathf.Abs (origin.y - touchPos.y) / Mathf.Abs (origin.x - touchPos.x));
if ((origin.y<touchPos.y && origin.x >touchPos.x)||(touchPos.y<origin.y && touchPos.x >origin.x)) {
angle*= -1;
}
``````

I think problem is here getting the angle .Then I am changing the position of the object like this :

``````float x = Mathf.Cos (angle) * 2f + origin.x;
float y = Mathf.Sin (angle) * 2f + origin.y;
toDragg.position = new Vector3 (x,y,0f);
``````

Please help me somebody solving this problem . I have stuck here , tried to solve in many ways but no improvement .

You don’t need any angles for this.

``````Vector3 v = touchPos - origin;
Vector3 new_pos = origin + v.normalized * circle_radius;
``````

@doublemax @OrajokNor The object is maintaining finger position rather than maintaining the radius.

public Transform origin; // origin publicaly in Editor
``````void Update()