diff --git a/BGC/FP32Vector2.cs b/BGC/FP32Vector2.cs index 0f4c9f2..adbd69a 100644 --- a/BGC/FP32Vector2.cs +++ b/BGC/FP32Vector2.cs @@ -193,33 +193,33 @@ namespace BGC public static float GetAngle(in FP32Vector2 vector1, in FP32Vector2 vector2, AngleUnit unit) { - float squareModule1 = vector1.GetSquareModule(); + float squareModule1 = vector1.GetSquareModule(); - if (squareModule1 <= FP32Utility.SQUARE_EPSYLON) - { - return 0.0f; - } - - float squareModule2 = vector2.GetSquareModule(); - - if (squareModule2 <= FP32Utility.SQUARE_EPSYLON) - { - return 0.0f; - } - - float cosine = FP32Vector2.GetScalarProduct(vector1, vector2) / MathF.Sqrt(squareModule1 * squareModule2); - - if (1.0f - FP32Utility.EPSYLON <= cosine) + if (squareModule1 <= FP32Utility.SQUARE_EPSYLON) { return 0.0f; - } + } - if (cosine <= -(1.0f - FP32Utility.EPSYLON)) + float squareModule2 = vector2.GetSquareModule(); + + if (squareModule2 <= FP32Utility.SQUARE_EPSYLON) + { + return 0.0f; + } + + float cosine = FP32Vector2.GetScalarProduct(vector1, vector2) / MathF.Sqrt(squareModule1 * squareModule2); + + if (1.0f - FP32Utility.EPSYLON <= cosine) + { + return 0.0f; + } + + if (cosine <= -(1.0f - FP32Utility.EPSYLON)) { return FP32Angle.GetHalfCircle(unit); - } + } - return FP32Radians.ToUnits(MathF.Acos(cosine), unit); + return FP32Radians.ToUnits(MathF.Acos(cosine), unit); } public static float GetSquareDistance(in FP32Vector2 vector1, in FP32Vector2 vector2) diff --git a/BGC/FP32Vector3.cs b/BGC/FP32Vector3.cs index d67eb9f..1ae9290 100644 --- a/BGC/FP32Vector3.cs +++ b/BGC/FP32Vector3.cs @@ -236,33 +236,33 @@ namespace BGC public static float GetAngle(in FP32Vector3 vector1, in FP32Vector3 vector2, AngleUnit unit) { - float squareModule1 = vector1.GetSquareModule(); + float squareModule1 = vector1.GetSquareModule(); - if (squareModule1 <= FP32Utility.SQUARE_EPSYLON) - { - return 0.0f; - } - - float squareModule2 = vector2.GetSquareModule(); - - if (squareModule2 <= FP32Utility.SQUARE_EPSYLON) - { - return 0.0f; - } - - float cosine = FP32Vector3.GetScalarProduct(vector1, vector2) / MathF.Sqrt(squareModule1 * squareModule2); - - if (1.0f - FP32Utility.EPSYLON <= cosine) + if (squareModule1 <= FP32Utility.SQUARE_EPSYLON) { return 0.0f; - } + } - if (cosine <= -(1.0f - FP32Utility.EPSYLON)) + float squareModule2 = vector2.GetSquareModule(); + + if (squareModule2 <= FP32Utility.SQUARE_EPSYLON) + { + return 0.0f; + } + + float cosine = FP32Vector3.GetScalarProduct(vector1, vector2) / MathF.Sqrt(squareModule1 * squareModule2); + + if (1.0f - FP32Utility.EPSYLON <= cosine) + { + return 0.0f; + } + + if (cosine <= -(1.0f - FP32Utility.EPSYLON)) { return FP32Angle.GetHalfCircle(unit); - } + } - return FP32Radians.ToUnits(MathF.Acos(cosine), unit); + return FP32Radians.ToUnits(MathF.Acos(cosine), unit); } public static float GetSquareDistance(in FP32Vector3 vector1, in FP32Vector3 vector2) diff --git a/BGC/FP64Vector2.cs b/BGC/FP64Vector2.cs index cb2513f..dbc081b 100644 --- a/BGC/FP64Vector2.cs +++ b/BGC/FP64Vector2.cs @@ -193,33 +193,33 @@ namespace BGC public static double GetAngle(in FP64Vector2 vector1, in FP64Vector2 vector2, AngleUnit unit) { - double squareModule1 = vector1.GetSquareModule(); + double squareModule1 = vector1.GetSquareModule(); - if (squareModule1 <= FP64Utility.SQUARE_EPSYLON) - { - return 0.0; - } - - double squareModule2 = vector2.GetSquareModule(); - - if (squareModule2 <= FP64Utility.SQUARE_EPSYLON) - { - return 0.0; - } - - double cosine = FP64Vector2.GetScalarProduct(vector1, vector2) / Math.Sqrt(squareModule1 * squareModule2); - - if (1.0 - FP64Utility.EPSYLON <= cosine) + if (squareModule1 <= FP64Utility.SQUARE_EPSYLON) { return 0.0; - } + } - if (cosine <= -(1.0 - FP64Utility.EPSYLON)) + double squareModule2 = vector2.GetSquareModule(); + + if (squareModule2 <= FP64Utility.SQUARE_EPSYLON) + { + return 0.0; + } + + double cosine = FP64Vector2.GetScalarProduct(vector1, vector2) / Math.Sqrt(squareModule1 * squareModule2); + + if (1.0 - FP64Utility.EPSYLON <= cosine) + { + return 0.0; + } + + if (cosine <= -(1.0 - FP64Utility.EPSYLON)) { return FP64Angle.GetHalfCircle(unit); - } + } - return FP64Radians.ToUnits(Math.Acos(cosine), unit); + return FP64Radians.ToUnits(Math.Acos(cosine), unit); } public static double GetSquareDistance(in FP64Vector2 vector1, in FP64Vector2 vector2) diff --git a/BGC/FP64Vector3.cs b/BGC/FP64Vector3.cs index e1620fb..4829ffd 100644 --- a/BGC/FP64Vector3.cs +++ b/BGC/FP64Vector3.cs @@ -236,33 +236,33 @@ namespace BGC public static double GetAngle(in FP64Vector3 vector1, in FP64Vector3 vector2, AngleUnit unit) { - double squareModule1 = vector1.GetSquareModule(); + double squareModule1 = vector1.GetSquareModule(); - if (squareModule1 <= FP64Utility.SQUARE_EPSYLON) - { - return 0.0; - } - - double squareModule2 = vector2.GetSquareModule(); - - if (squareModule2 <= FP64Utility.SQUARE_EPSYLON) - { - return 0.0; - } - - double cosine = FP64Vector3.GetScalarProduct(vector1, vector2) / Math.Sqrt(squareModule1 * squareModule2); - - if (1.0 - FP64Utility.EPSYLON <= cosine) + if (squareModule1 <= FP64Utility.SQUARE_EPSYLON) { return 0.0; - } + } - if (cosine <= -(1.0 - FP64Utility.EPSYLON)) + double squareModule2 = vector2.GetSquareModule(); + + if (squareModule2 <= FP64Utility.SQUARE_EPSYLON) + { + return 0.0; + } + + double cosine = FP64Vector3.GetScalarProduct(vector1, vector2) / Math.Sqrt(squareModule1 * squareModule2); + + if (1.0 - FP64Utility.EPSYLON <= cosine) + { + return 0.0; + } + + if (cosine <= -(1.0 - FP64Utility.EPSYLON)) { return FP64Angle.GetHalfCircle(unit); - } + } - return FP64Radians.ToUnits(Math.Acos(cosine), unit); + return FP64Radians.ToUnits(Math.Acos(cosine), unit); } public static double GetSquareDistance(in FP64Vector3 vector1, in FP64Vector3 vector2)