Большая реорганизация проекта
This commit is contained in:
parent
233c027d46
commit
f3b0232dd4
35 changed files with 705 additions and 593 deletions
48
BasicGeometry/UtilityFP32.cs
Normal file
48
BasicGeometry/UtilityFP32.cs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
using System;
|
||||
|
||||
namespace BasicGeometry
|
||||
{
|
||||
public class UtilityFP32
|
||||
{
|
||||
public const float EPSYLON = 4.76837E-7f;
|
||||
public const float SQUARE_EPSYLON = 2.27373906E-13f;
|
||||
|
||||
public const float EPSYLON_EFFECTIVENESS_LIMIT = 1.0f;
|
||||
|
||||
public const float ONE_THIRD = 0.333333333f;
|
||||
public const float ONE_SIXTH = 0.166666667f;
|
||||
public const float ONE_NINETH = 0.111111111f;
|
||||
|
||||
public const float GOLDEN_RATIO_HIGH = 1.618034f;
|
||||
public const float GOLDEN_RATIO_LOW = 0.618034f;
|
||||
|
||||
public static bool IsZero(float value)
|
||||
{
|
||||
return -EPSYLON <= value && value <= EPSYLON;
|
||||
}
|
||||
|
||||
public static bool IsUnit(float value)
|
||||
{
|
||||
return (1.0f - EPSYLON) <= value && value <= (1.0f + EPSYLON);
|
||||
}
|
||||
|
||||
public static bool IsSqareValueUnit(float square)
|
||||
{
|
||||
return (1.0f - 2.0f * EPSYLON) <= square && square <= (1.0f + 2.0f * EPSYLON);
|
||||
}
|
||||
|
||||
public static bool AreClose(float value1, float value2)
|
||||
{
|
||||
float difference = value1 - value2;
|
||||
float squareValue1 = value1 * value1;
|
||||
float squareValue2 = value2 * value2;
|
||||
float squareDifference = difference * difference;
|
||||
|
||||
if (squareValue1 <= EPSYLON_EFFECTIVENESS_LIMIT || squareValue2 <= EPSYLON_EFFECTIVENESS_LIMIT) {
|
||||
return squareDifference <= SQUARE_EPSYLON;
|
||||
}
|
||||
|
||||
return squareDifference <= SQUARE_EPSYLON * squareValue1 && squareDifference <= SQUARE_EPSYLON * squareValue2;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue