- Home /

# Issue finding an angle with trigonometry

I am following this tutorial by Sebastian Lague: https://youtu.be/jUdx_Nj4Xk0?t=718 At 11:58 in the video (The timemark is in the link) he is first getting the direction of the vector towards the target he wants to rotate towards, by subtracting the target position by transform.position. That part I understand, but what I would like to understand better is how he then gets the desired angle by taking the tangent of the target's x and z values. How does this give the wanted rotation angle? Any help would be much appreciated!

**Answer** by Bunny83
·
Oct 04, 2018 at 10:27 PM

He does not take the tangent of x and y but he takes the "arctan" of "y/x". The special atan2 method does the same but in addition it takes the quadrants into account and applies the proper 90° rotations to get a 360° result

The "tan" method takes an angle in radians and calulates the length of the tangent on the unit circle. The atan method does the reverse. You pass in the length of the tangent and it returns the angle. This only works properly for the first (main) quadrant of the coordinate system. Though since atan2 gets y and x seperately it can analyse the sign of x and y and apply the quadrant corrections. I'm not sure what else we can say here. It's just basic trigonometry. By dividing y by x we get the length of the tangent on the unit circle y / x == tan(a) / 1

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

Set rotation based on 1,1,1 style vector? How to convert vector3 to quaternion? 1 Answer

rotation x changes all angles? 3 Answers

Vector3.SignedAngle wrong direction when crossing the 0 point 1 Answer

Interpolate a rotation with angle axis 1 Answer

Pointing object at mouse using raycast only works when object is center screen. 2 Answers