Closed brmassa closed 2 months ago
instead of a threshold maybe create a custom comparison check? That uses Application.FloatEqualThreshold
instead of a threshold maybe create a custom comparison check? That uses
Application.FloatEqualThreshold
- [ ] Math.FloatIsEqual(floatValue, comparedTo)
- [ ] Math.FloatIsGreater(floatValue, comparedTo)
- [ ] Math.FloatIsLesser(floatValue, comparedTo)
This is a good point Unity has Mathf.ApproximatelyEquals, Since our goal is to sorta mimic Unity's API to make transitioning as seamless as possible, it makes sense to recreate that idea.
I agree with all comments:
Mathf.ApproximatelyEquals
: good option. Also, I've arbitrarily chosen 0.0001f. It would be nice to check the value selected by UnityMath.*
methods make it more readable. a what about using `Mathf.? b* A operator
==` override (for floats and doubles)?I've created Mathf.ApproximatelyEquals because it's the same method name used for MathD.
Also, I replaced several Epsilon comparisons with the Mathf.Epsilon and MathD.Epsilon
single
anddouble
floats use an especial arithmetic that uses a trade-off of being super big/small, but not very precise.Eventually, 100f - 10f might result in
90.000000001
instead of pure90f
, so when comparing if 2 floats are the same, we need actually to check if they are close enough. Doing the pure comparison might result in weird behaviors.0.0001f
)