namespace UnityEngine
{
public struct Mathf
{
public const float PI = 3.14159274F;
public const float Infinity = float.PositiveInfinity;
public const float NegativeInfinity = float.NegativeInfinity;
// 1 角度 等于 0.0174532924F 弧度
public const float Deg2Rad = 0.0174532924F;
// 1 弧度 等于 57.29578F 角度
public const float Rad2Deg = 57.29578F;
//一个微小的浮点值 不知道什么意义
public static readonly float Epsilon;
public static float Abs(float f);
public static int Abs(int value);
//反余弦 弧度
public static float Acos(float f);
//比较两个浮点值,如果它们相似则返回true。 这得有多相似才行啊?
public static bool Approximately(float a, float b);
//反正弦
public static float Asin(float f);
//反正切 返回值介于负二分之 pi 与 正二分之 pi 之间
public static float Atan(float f);
//返回 Tan(y/x)的弧度角度。
public static float Atan2(float y, float x);
//返回大于或等于 f 的最小整数。 进一法取整
public static float Ceil(float f);
//返回大于或等于 f 的最小整数。 和 Ceil() 有区别吗
public static int CeilToInt(float f);
//
public static int Clamp(int value, int min, int max);
//
public static float Clamp(float value, float min, float max);
//
public static float Clamp01(float value);
//Returns the closest power of two value.
//返回最接近value的 2的n次幂 (2的幂) 为什么 value=6,返回是8,而不是4,取大值?
public static int ClosestPowerOfTwo(int value);
//把色温转换为颜色 kelvin(1000-40000)
public static Color CorrelatedColorTemperatureToRGB(float kelvin);
public static float Cos(float f);
//计算两个给定角度(以度数表示)之间的最短差。
public static float DeltaAngle(float current, float target);
//返回e的指定次方。 e的n次幂
public static float Exp(float power);
//暂未知
public static ushort FloatToHalf(float val);
//返回小于或等于f的最大整数。 舍弃法取整
public static float Floor(float f);
public static int FloorToInt(float f);
//伽马函数 暂未知
public static float Gamma(float value, float absmax, float gamma);
//暂未知
public static float GammaToLinearSpace(float value);
//暂未知
public static float HalfToFloat(ushort val);
//反插值 value在 a 和 b 之间的比例值
public static float InverseLerp(float a, float b, float value);
// 如果值是2的幂,则返回true。
public static bool IsPowerOfTwo(int value);
public static float Lerp(float a, float b, float t);
//还不知道参数不在 0-360 范围内会怎样
public static float LerpAngle(float a, float b, float t)
public static float LerpUnclamped(float a, float b, float t);
// 暂未知
public static float LinearToGammaSpace(float value);
// 以 f 为底 p 的对数
public static float Log(float f, float p);
// 以 e 为底 f 的对数
public static float Log(float f);
// 以 10 为底 f 的对数
public static float Log10(float f);
public static int Max(int a, int b);
public static float Max(params float[] values);
public static float Max(float a, float b);
public static int Max(params int[] 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)
public static float MoveTowards(float current, float target, float maxDelta);
public static float MoveTowardsAngle(float current, float target, float maxDelta);
//
public static int NextPowerOfTwo(int value);
// 不知道啥意思 值介于0.0和1.0之间。(返回值可能略低于0.0或大于1.0)
public static float PerlinNoise(float x, float y);
//乒乓 t一般为变值 返回值(0 - length)
//实现原理是 判断倍数奇偶,再求余,再运算。
//如果当前的 T 除去最大 L,倍数为双时,则进行求模运算,%,
//倍数单时,返回值 R = L-(当前值 T % 最大值 L)
public static float PingPong(float t, float length);
//返回 f 的 p 次方。
public static float Pow(float f, float p);
//重复
public static float Repeat(float t, float length);
//四舍五入
public static float Round(float f);
//
public static int RoundToInt(float f);
//返回 f 的符号
public static float Sign(float f);
public static float Sin(float f);
//随着时间的推移逐渐改变一个值到期望值。 这个值就像被一个不会崩溃的弹簧减振器一样被平滑。
//这个函数可以用来平滑任何类型的值,位置,颜色,标量。
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);
// current 当前的位置,target 我们试图达到的位置,currentVelocity 当前速度,这个值在你访问这个函数的时候会被随时修改。
//smoothTime 要到达目标位置的近似时间,实际到达目标时要快一些。
//maxSpeed 可选参数,允许你限制的最大速度。
//deltaTime 上次调用该函数到现在的时间。缺省为Time.deltaTime。
public static float SmoothDamp(float current, float target, ref float currentVelocity, float smoothTime, [DefaultValue("Mathf.Infinity")] float maxSpeed, [DefaultValue("Time.deltaTime")] float deltaTime);
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);
public static float SmoothDampAngle(float current, float target, ref float currentVelocity, float smoothTime, [DefaultValue("Mathf.Infinity")] float maxSpeed, [DefaultValue("Time.deltaTime")] float deltaTime);
//在最小值和最大值之间插值,在极限处平滑。(在限制处渐入渐出)
public static float SmoothStep(float from, float to, float t);
//给 f 开平方
public static float Sqrt(float f);
public static float Tan(float f);
}
}
Unity Mathf
于 2021-07-28 15:09:01 首次发布