Unity 常用脚本:Mathf

 public const float PI = 3.14159274F;

摘要:圆周率的值。 

public static float Abs(float f);

摘要:Returns the absolute value of f. 返回f的绝对值,参数为float

public static int Abs(int value);

摘要:Returns the absolute value of value. 返回value的绝对值,参数为int

public static float Ceil(float f);

摘要:Returns the smallest integer greater to or equal to f. 返回大于或等于f的最小整数。返回值为float

public static int CeilToInt(float f);

摘要:Returns the smallest integer greater to or equal to f. 返回大于或等于f的最小整数。 返回值为int

public static float Clamp(float value, float min, float max);

摘要:Clamps the given value between the given minimum float and maximum float values.Returns the given value if it is within the min and max range.

如果value在min与max之间,返回value。如果value小于min,返回min。如果value大于max,返回max。

 public static int Clamp(int value, int min, int max);

摘要:同上,参数为int

public static float Clamp01(float value);

摘要:Clamps value between 0 and 1 and returns value. 

如果value在0与1之间,返回value。如果value小于0,返回0。如果value大于1,返回1。

public static int ClosestPowerOfTwo(int value);

摘要:Returns the closest power of two value. 返回距离value最近的2的次方数。

public static float DeltaAngle(float current, float target);

摘要:Calculates the shortest difference between two given angles given in degrees. 计算以度为单位的两个给定角度之间的最小差值。

public static float Floor(float f);

摘要:Returns the largest integer smaller to or equal to f. 返回小于或等于f的最大整数。

public static int FloorToInt(float f);

摘要:Returns the largest integer smaller to or equal to f. 返回小于或等于f的最大整数。 

public static bool IsPowerOfTwo(int value); 

摘要:Returns true if the value is power of two. 如果值是2的幂,则返回true。

public static float Lerp(float a, float b, float t); 

摘要:Linearly interpolates between a and b by t. 用t在a和b之间做线性插值。

public static float LerpAngle(float a, float b, float t);

摘要:Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees. 

与Lerp相同,但要确保值在360度左右正确插值。

public static float LerpUnclamped(float a, float b, float t);

摘要:Linearly interpolates between a and b by t with no limit to t.用t在a和b之间进行线性插值,不受t的限制。 

 public static float Log(float f, float p);

摘要:Returns the logarithm of a specified number in a specified base. 返回指定基数中指定数字的对数。

如果a的x次方等于N(a>0,且a不等于1),那么数x叫做以a为底N的对数。其中,a叫做对数的底数,N叫做真数。

f:真数;p:底数。

public static float Log10(float f);

摘要:Returns the base 10 logarithm of a specified number. 返回指定数字的以10为底的对数。

public static int Max(int a, int b);

public static float Max(params float[] values); 

public static int Max(params int[] values); 

摘要:Returns the largest of two or more values. 返回两个或多个值中最大的一个。 

public static int Min(params int[] values);

public static int Min(int a, int b);

public static float Min(params float[] values);

public static float Min(float a, float b);

摘要:Returns the smallest of two or more values. 返回两个或多个值中最小的值。

public static float MoveTowards(float current, float target, float maxDelta); 

摘要:Moves a value current towards target. 将当前值移动到目标。

和Mathf.Lerp相同,而是该函数将确保我们的速度不会超过maxDelta。

参数:
current:The current value.当前值。
target:The value to move towards.目标值
maxDelta:The maximum change that should be applied to the value.应用于该值的最大更改。

public static float MoveTowardsAngle(float current, float target, float maxDelta);

摘要:Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees. 

和movetoward一样,但是要确保当它们环绕360度时插值正确。

public static int NextPowerOfTwo(int value);

摘要:Returns the next power of two value. 返回2的下一个幂。

public static float Pow(float f, float p);

摘要:Returns f raised to power p. 返回f的p次方。

public static float Round(float f);

public static int RoundToInt(float f);

摘要:Returns f rounded to the nearest integer. 返回四舍五入到最近整数的f。

public static float Sign(float f);

摘要:Returns the sign of f. 返回f的符号。

public static float Sqrt(float f);

摘要:Returns square root of f. 返回f的平方根。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值