- Home /

# problem with mathf.tan

can i calculate the angle with its tangent in a java script?

Comment

Best Answer

**Answer** by Cyclops
·
Apr 04, 2010 at 04:37 PM

It's fairly simple: Mathf.Tan(angle).

```
print (Mathf.Tan(0.5));
```

Note that the angle must be Radians, so if you have a value in Degrees, you need to convert, like this:

```
var deg = 45;
var rad = deg * Mathf.PI / 180;
print (Mathf.Tan(rad));
```

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