- 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 * $$anonymous$$athf.Cos(dragAngle * $$anonymous$$athf.PI/180)*dragDist;
movement.z = 1 * $$anonymous$$athf.Sin(dragAngle * $$anonymous$$athf.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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.