Version: Unity 6.2 Alpha (6000.2)
LanguageEnglish
  • C#

Mathf.Tan

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual

Declaration

public static float Tan(float f);

Parameters

f The input angle, in radians.

Returns

float The return value in the range (-Infinity, Infinity).

Description

Returns the tangent of angle f in radians.

The tangent trigonometric function has two properties than are worth considering: - It has two vertical asymptotes at f = ±π/2. This means that when approaching these f values, the output of the function will grow towards ±Infinity (without ever reaching them). - It is periodic at π intervals, which means that the output for a value f will be the same than the output for value f + π (or 2π, 3π, etc.)

Additional resources: Cos, Sin.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Example() { // Prints 2.287733E+07 Debug.Log(Mathf.Tan(-Mathf.PI / 2.0f)); // Prints 0 Debug.Log(Mathf.Tan(0.0f)); // Prints 2.287733E+07 Debug.Log(Mathf.Tan(Mathf.PI / 2.0f)); // Prints 1 Debug.Log(Mathf.Tan(Mathf.PI / 4.0f)); // Prints 1 Debug.Log(Mathf.Tan(Mathf.PI + Mathf.PI / 4.0f)); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961