- Home /

# How to calculate a new position having angle and distance?

How to calculate a new position having angle and distance in two-dimentional space? Thanks!

**Answer** by robertbu
·
Jul 12, 2013 at 06:43 AM

You can use polar coordinates.

```
var x = dist * cos(angle * Mathf.Deg2Rad);
var y = dist * sin(angle * Mathf.Deg2Rad);
var newPosition = currentPosition;
newPosition.x += x;
newPosition.y += y;
```

Or solve it using a Quaternion (assumes camera is looking towards positive 'Z'). Also assumes Vector3.right is the basis for the angle:

```
var q = Quaternion.AngleAxis(angle, Vector3.forward);
newPosition = currentPosition + q * Vector3.right * distance;
```

Thanks! This also works

```
Vector3 movement = Vector3.zero;
movement.x = 1 * Mathf.Cos(dragAngle * Mathf.PI/180)*dragDist;
movement.z = 1 * Mathf.Sin(dragAngle * Mathf.PI/180)*dragDist;
```

But, if you use sin/cos then your angles run counter-clockwise from East. At some point you may need to use "game programmer" angles, which run clock-wise from North.

Sure, you can convert ( -1*(a-90)?,) but sometimes it's easier just to use 0=North angles and built-in angle functions for everything.

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.