UNITY 5.2 Mathf 结构

此结构体只有静态变量和静态方法,不需要用对象

Static变量:

public const float Deg2Rad = 0.0174533f;
说明:将角度转换为弧度, 弧度 = 角度 * PI / 180, Deg2Rad 相当于 2 * PI / 360
public const float Rad2Deg = 57.2958f;
说明:将弧度转换为角度, 角度 = 弧度 * 180 / PI,Rad2Deg 相当于 360 / 2 / PI
public static readonly float Epsilon;
说明:一个很小的浮点数,仅仅大于 0
public const float Infinity = 1.0f / 0.0f;
public const float NegativeInfinity = -1.0f / 0.0f;
说明:正无穷大,负无穷大
public const float PI = 3.14159f;
说明:圆周率

Static方法:

public static float Abs(float f);
public static int Abs(int value);
说明:获取整数或者浮点数的绝对值
public static float Asin(float f);
说明:反正弦函数,返回弧度值
public static float Acos(float f);
说明:反余弦函数,返回弧度值
public static float Atan(float f);
说明:反正切函数,返回弧度值
public static float Atan2(float y, float x);
说明:返回正切值为 y/x 的弧度
public static bool Approximately(float a, float b);
说明:判断两个浮点数是否相等,一般不要用 == 
public static float Ceil(float f);
public static int CeilToInt(float f);
说明:返回一个最小的不比 f 小的整数
public static float Clamp(float value, float min, float max);
public static int Clamp(int value, int min, int max);
说明:若 value 在 min 和 max 之间,则返回 value,否则返回 min 或者 max
public static float Clamp01(float value);
说明:若 value 在 0 - 1 之间则返回 value,否则返回 0 或者 1
public static int ClosestPowerOfTwo(int value);
说明:返回与 value 最相近的 2 的整数幂的数
public static float Sin(float f);
说明:求弧度 f 的正弦
public static float Cos(float f);
说明:求弧度 f 的余弦
public static float Tan(float f);
说明:求弧度 f 的正切
public static float DeltaAngle(float current, float target);
说明:计算两个角度间的最小差
public static float Exp(float power);
说明:返回自然数 e 的 power 次幂的值
public static float Floor(float f);
public static int FloorToInt(float f);
说明:返回不大于 f 的最大整数
public static float GammaToLinearSpace(float value);
说明:将 value 从 gamma 转换到线性的值
public static float InverseLerp(float a, float b, float value);
说明:返回 value 在 a b 间的线性参数
public static bool IsPowerOfTwo(int value);
说明:判断是否为 2 的整数次幂
public static float Lerp(float a, float b, float t);
说明:返回 a b 间的线性差值, t [0, 1]
public static float LerpAngle(float a, float b, float t);
说明:返回 a b 角度间的线性差值, a b 相差 360°  t [0, 1]
public static float LerpUnclamped(float a, float b, float t);
说明:t 在 [0, 1] 返回 a b 间的值,若超出,则会超出a b
public static float LinearToGammaSpace(float value)
说明:将 value 从线性控件转换到 gamma 空间
public static float Log(float f, float p);
说明:返回以 p 为底, f 的对数
public static float Log(float f);
说明:返回以 e 为底, f 的对数
public static float Log10(float f);
说明:返回以 10 为底,f 的对数
public static float Max(params float[] values);
public static int Max(params int[] values);
public static float Max(float a, float b);
public static int Max(int a, int b);
public static float Min(params float[] values);
public static int Min(params int[] values);
public static float Min(float a, float b);
public static int Min(int a, int b);
说明:返回数组或者两个数中的最大或者最小值
public static float MoveTowards(float current, float target, float maxDelta);
说明:将 current 往 target 移动最大 maxDelta
public static float MoveTowardsAngle(float current, float target, float maxDelta);
说明:将 current 度数往 target 移动最大 maxDelta,不支持赋值,远离最大则为 180
public static int NextPowerOfTwo(int value);
说明:返回下一个2的整数次幂的数
public static float PingPong(float t, float length);
说明:保证 t 不小于 0 和 不大于 length
public static float Pow(float f, float p);
说明:f 的 p 次幂
public static float Repeat(float t, float length);
说明:浮点数取余
public static float Round(float f);
public static int RoundToInt(float f);
说明:四舍五入,基数 5 入,偶数 5 舍
public static float Sign(float f);
说明:f >= 0 则返回 1 否则为 -1
public static float Sqrt(float f);
说明:返回 f 的平方根


PASS:实在受不了了
public static float SmoothDamp(float current, float target, ref float currentVelocity, float smoothTime);
public static float SmoothDamp(float current, float target, ref float currentVelocity, float smoothTime, float maxSpeed);
public static float SmoothDamp(float current, float target, ref float currentVelocity, float smoothTime, float maxSpeed, float deltaTime);
public static float SmoothDampAngle(float current, float target, ref float currentVelocity, float smoothTime);
public static float SmoothDampAngle(float current, float target, ref float currentVelocity, float smoothTime, float maxSpeed);
public static float SmoothDampAngle(float current, float target, ref float currentVelocity, float smoothTime, float maxSpeed, float deltaTime);
public static float SmoothStep(float from, float to, float t);
public static float PerlinNoise(float x, float y);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值