Unity 关于角度值和弧度值互转

弧度和角度

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Test15 : MonoBehaviour
{
    private float angle = 30f;//角度值
    private float rad = 0.5f;//弧度值
    /// <summary>
    /// Mathf.Rad2Deg 等同于 (360/(2*Mathf.PI))
    /// Mathf.Deg2Rad 等同于 (2 * Mathf.PI) / 360)
    /// Mathf.Deg2Rad * (Mathf.Rad2Deg)=1,倒数关系
    /// x=sinθ(θ∈ [0,2π) ) θ 属于弧度值 同理cos tan 一样
    /// Asin Acos Atan 参数也要为弧度值
    /// </summary>
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.A))
        {
            Debug.LogError(Mathf.Rad2Deg + "<>" + (360 / (2 * Mathf.PI)));//57.29578<>57.29578 两个数值相等
            Debug.LogError(Mathf.Deg2Rad + "<>" + (2 * Mathf.PI) / 360);//0.01745329<>0.01745329 两个数值相等
            Debug.LogError(Mathf.Deg2Rad * (Mathf.Rad2Deg));//1
            Debug.LogError(Mathf.Sin(angle / Mathf.Rad2Deg));//0.5 弧度值
            Debug.LogError(Mathf.Sin(angle * Mathf.Deg2Rad));//0.5 弧度值
            Debug.LogError(Mathf.Asin(rad)* Mathf.Rad2Deg);//30  角度值
        }
    }
}
posted @ 2020-12-03 11:01  低小调  阅读(504)  评论(0编辑  收藏  举报