- Home /

# Finding the x and y of Mathf.Atan2 after converted to degrees

Hello I'm trying to figure out how solve the x and y of Math.Atan2 after it is calculated and converted into a Degree using Mathf.Rad2Deg since I want to add a small change in the angle like 15 degrees or so which can be changable. I am mainly trying to implement this so I can have a 2d platformer directional shooter that shoots multiple bullets at once for my enemies to add more difficulty to the game

```
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public float y;
public float x;
public class PointAndShoot : MonoBehaviour
{
void FixedUpdate() {
float rotationZ = Mathf.Atan2(y, x) * Mathf.Rad2Deg;
//Want to figure out if its possible to add or subtract degrees from rotationZ and figure out what the
//x and y are in that degree angle
}
}
```

**Answer** by Namey5
·
Apr 08 at 04:16 AM

You can figure out where the new point [x,y] would be through trig identities;

```
//Calculate angle theta
float theta = Mathf.Atan2(y, x) * Mathf.Rad2Deg;
//Make whatever change you want to the angle, in this case subtract 10 degrees
theta -= 10f;
//Let's say we have an angle 'a', which we get from 'a = atan2 (y, x)'
//'atan' is the inverse of 'tan', therefore 'atan (tan (a)) = a'
//We also know that 'tan (a) = sin (a) / cos (a)'
//Therefore 'atan (sin (a) / cos (a)) = a'
//You'll notice that 'Vector2 (cos (a), sin (a))' is a point on the circumference of a unit circle rotated 'a' degrees
//This is actually the basis of how 'atan2' is calculated in the first place, i.e. 'atan2 (y, x) ~ atan (y / x)' (not strictly correct, but close enough for this example)
//Therefore, for a point/vector at 'theta' degrees; x = cos (theta), y = sin (theta)
float newX = Mathf.Cos (theta * Mathf.DegToRad);
float newY = Mathf.Sin (theta * Mathf.DegToRad);
```

You can read more about atan2 here;

### 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.

### Follow this Question

### Related Questions

how can i determine the angle of the face of an object relative to the world? 0 Answers

user input azimuth and elevation angle. Need Urgent Help 0 Answers

Setting rotation Angle / rotation question 1 Answer

Rotation around a moving object. 0 Answers

Camera rotating super fast when trying to match the camera and players Y euler angle. 1 Answer