Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Acos(float)

Returns the arc-cosine of f - the angle in radians whose cosine is f.
Read time 1 minuteLast updated 5 days ago

Definition

  • Type: Method
  • Namespace: UnityEngine
  • Assembly: UnityEngine.CoreModule
public static float Acos(float f)

Parameters

Value to compute the arc-cosine for, in the range [-1,1].

Returns

Type

Description

floatAngle in radians whose cosine equals
f
, in the range [0, Pi].

Remarks

For values of
f
outside of the [-1,1] range, this function will return NaN.
Additional Resources: Mathf.Cos.

Examples

using UnityEngine;public class ScriptExample : MonoBehaviour{ void Start() { // Prints NaN Debug.Log(Mathf.Acos(-1.0000001f)); // Prints 3.141593 Debug.Log(Mathf.Acos(-1)); // Prints 1.570796 Debug.Log(Mathf.Acos(0)); // Prints 0 Debug.Log(Mathf.Acos(1)); // Prints NaN Debug.Log(Mathf.Acos(1.0000001f)); }}