/// <summary> /// <para>Clamps the Vector2Int to the bounds given by min and max.</para> /// </summary> /// <param name="min"></param> /// <param name="max"></param> public void Clamp(LVector2Int min, LVector2Int max) { this.x = LMath.Max(min.x, this.x); this.x = LMath.Min(max.x, this.x); this.y = LMath.Max(min.y, this.y); this.y = LMath.Min(max.y, this.y); }
/// <summary> /// 向目标角度旋转 /// </summary> /// <param name="from"></param> /// <param name="to"></param> /// <param name="maxDegreesDelta"></param> /// <returns></returns> public static LQuaternion RotateTowards(LQuaternion from, LQuaternion to, LFloat maxDegreesDelta) { LFloat num = LQuaternion.Angle(from, to); LQuaternion result = new LQuaternion(); if (num == 0) { result = to; } else { LFloat t = LMath.Min(LFloat.one, maxDegreesDelta / num); result = LQuaternion.SlerpUnclamped(from, to, t); } return(result); }
/// <summary> /// 夹角大小 /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> public static LFloat Angle(LQuaternion a, LQuaternion b) { LFloat single = Dot(a, b); return(LMath.Acos(LMath.Min(LMath.Abs(single), LFloat.one)) * 2 * (180 / LMath.PI)); }
public void Min(ref LVector2 r) { this._x = LMath.Min(this._x, r._x); this._y = LMath.Min(this._y, r._y); }
/// <summary> /// 获取 最大值 /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> public static LVector2 Min(LVector2 a, LVector2 b) { return(new LVector2(true, LMath.Min(a._x, b._x), LMath.Min(a._y, b._y))); }