码迷,mamicode.com
首页 > 编程语言 > 详细

unity API :Mathf

时间:2020-07-17 13:37:49      阅读:83      评论:0      收藏:0      [点我收藏+]

标签:family   soft   init   允许   计算   颜色   hellip   com   次方   

  1. Mathf.Log(a,b);返回以b为底,a为真数的对数,如果b为无理数e(e=2.71828…),那么称之为自然对数
  2. Mathf.Log10(a),返回以10为底,a为真数的对数,也称之为常用对数
  3. Mathf.Abs(a),返回a的绝对值.
  4. Mathf.Cos(a),返回a(a单位为弧度,取值(-π , π))的余弦值,结果区间为(-1,1).
  5. Mathf.Acos(a),返回a(a为余弦值,取值(-1 , 1))的弧度值,结果区间为(-π,π).
  6. Mathf.Sin(a),返回a(a单位为弧度,取值(-π , π))的正弦值,结果区间为(-1,1).
  7. Mathf.Asin(a),返回a(a单位为正弦值,取值(-1 , 1))的正弦值,结果区间为(-π,π).
  8. Mathf.Tan(a),返回a(a单位为弧度,取值(-π/2 , π/2))的正切值,结果区间为(-无穷大,无穷大).
  9. Mathf.Atan(a),返回a(a单位为正切值,取值(-无穷大 , 无穷大))的正切值,结果区间为(-π/2,π/2).
  10. Mathf.CeilToInt(a),返回大于或等于a的最小整数,如果a=2,那么返回2,如果a=1.9,返回2,如果a=2.1,则返回3
  11. Mathf.FloorToInt(a),返回小于或等于a的最大整数,如果a=2,那么返回2,如果a=1,返回2,如果a=2.1,则返回2
  12. Mathf.Clamp(a,b),返回取值介于a和b之间的一个数,大于或等于a,小于或等于b。
  13. Mathf.Clamp01,返回取值介于0和1之间的一个数,大于或等于0,小于或等于1。
  14. Mathf.Deg2Rad,度专弧度
  15. Mathf.Rad2Deg,弧度专度
  16. Mathf.DeltaAngle(a,b),增量角,返回角度a到角度b的最小角度增量(取值-180,180),Mathf.DeltaAngle(30,60)=30,Mathf.DeltaAngle(30,270)=-120.

  17. Mathf.Lerp (a,b,t) ,基于浮点数t返回a到b之间的插值,t限制在0~1之间。当t = 0返回a,当t = 1 返回b。当t = 0.5 返回a和b的平均值。


     

  18. Mathf.SmoothDampAngle平滑阻尼角度
    static float SmoothDampAngle (float current , float target  , ref float currentVelocity  , float smoothTime  ,float maxSpeed  = Mathf.Infinity,float  deltaTime = Time.deltaTime) 
    参数
    current:     当前的位置。
    target:       我们试图达到的位置。
    currentVelocity:   当前速度,这个值在你访问这个函数的时候会被随时修改。
    smoothTime : 要到达目标位置的近似时间,实际到达目标时要快一些。
    maxSpeed:  可选参数,允许你限制的最大速度。
    deltaTime:   上次调用该函数到现在的时间。缺省为Time.deltaTime。随着时间的推移逐渐改变一个给定的角度到期望的角度。这个值通过一些弹簧减震器类似的功能被平滑。这个函数可以用来平滑任何一种值,位置,颜色,标量。最常见的是平滑一个跟随摄像机。


     

  19. Mathf.SmoothDamp平滑阻尼
    static float SmoothDamp (float current ,float target  , ref float currentVelocity  , float smoothTime  ,float maxSpeed = Mathf.Infinity,float  deltaTime = Time.deltaTime) 
    参数
    current:  当前的位置。
    target:  我们试图达到的位置。
    currentVelocity:  当前速度,这个值在你访问这个函数的时候会被随时修改。
    smoothTime:  要到达目标位置的近似时间,实际到达目标时要快一些。
    maxSpeed:  可选参数,允许你限制的最大速度。
    deltaTime:  上次调用该函数到现在的时间。缺省为Time.deltaTime。


     

  20. Mathf.SmoothStep平滑插值
    static float SmoothStep (float from ,float to , float t ) 
    和lerp类似,在最小和最大值之间的插值,并在限制处渐入渐出。
  21. Mathf.Sqrt平方根
    static void float Sqrt (float f ) 计算并返回 f 的平方根。
  22. Mathf.Round四舍五入
    static float Round (float f ) 
    返回浮点数 f 进行四舍五入最接近的整数。
    如果数字末尾是.5,因此它是在两个整数中间,不管是偶数或是奇数,将返回偶数。
  23. Mathf.RoundToInt四舍五入到整数
    static int RoundToInt (float f ) 
    返回 f 指定的值四舍五入到最近的整数。
    如果数字末尾是.5,因此它是在两个整数中间,不管是偶数或是奇数,将返回偶数。
  24. Mathf.Pow次方
    static float Pow (float f , float p): 
    计算并返回 f 的 p 次方。
  25. Mathf.PI圆周率
    static float PI 
    PI(读pai)的值,也就是圆周率(π)的值3.14159265358979323846...(只读)
  26. Mathf.PingPong

    public static float PingPong(float t, float length);

    返回的是 0 - length中间数值 ,不会到0,也不会到length最大值

    t 只能用 Time.time,t 不能用固定数值,返回值将在0和length之间来回移动。1,2,3,4,3,2,1,2,3,4


     

  27. Mathf.Repeat

    public static float Repeat(float t, float length);

    返回的是 0 - length中间数值 ,不会到0,也不会到length最大值

    t 只能用 Time.time,t 不能用固定数值,返回值将在0和length之间重复移动。1,2,3,4,1,2,3,4,1


     

  28. Mathf.MoveTowards移向
    static function MoveTowards (float current , target : float, maxDelta : float) : float
    改变一个当前值向目标值靠近。
    这实际上和 Mathf.Lerp相同,而是该函数将确保我们的速度不会超过maxDelta。maxDelta为负值将目标从推离。

unity API :Mathf

标签:family   soft   init   允许   计算   颜色   hellip   com   次方   

原文地址:https://www.cnblogs.com/Dongzhu/p/13322965.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!