public void NormalizeWithoutChangingZ() { this.z = MBMath.ClampFloat(this.z, -0.99999f, 0.99999f); float length = this.AsVec2.Length; float num1 = MathF.Sqrt((float)(1.0 - (double)this.z * (double)this.z)); if ((double)length >= (double)num1 - 1.0000000116861E-07 && (double)length <= (double)num1 + 1.0000000116861E-07) { return; } if ((double)length > 9.99999971718069E-10) { float num2 = num1 / length; this.x *= num2; this.y *= num2; } else { this.x = 0.0f; this.y = num1; } }
public static int ClampIndex(int value, int minValue, int maxValue) => MBMath.ClampInt(value, minValue, maxValue - 1);
public static void ClampUnit(ref float value) => value = MBMath.ClampFloat(value, 0.0f, 1f);
public static float DistanceToLineSegmentSquared(Vec2 line1, Vec2 line2, Vec2 point) => point.DistanceSquared(MBMath.GetClosestPointInLineSegmentToPoint(point, line1, line2));