ExtendRealityLtd / Zinnia.Unity

A collection of design patterns for solving common problems.
http://vrtk.io
MIT License
319 stars 38 forks source link

FloatToBoolean Positive Bounds cannot be the same for an equality check #566

Closed thestonefox closed 2 years ago

thestonefox commented 2 years ago

If you use a FloatToBoolean and set the bounds min to 5 and the max to 5, then if the given float is 5 then it should be a true output boolean

fight4dream commented 2 years ago

from FloatToBoolean.cs

        protected override bool Process(float input)
        {
            return PositiveBounds.Contains(input);
        }

from FloatRange.cs

        public bool Contains(float value)
        {
            return value >= minimum && value <= maximum;
        }

from these code, if the bounds and the input values are all exactly 5, then it should have converted to true.

from the livestream, the input value was from the step value of AngularTransformDrive. I believe it may not exactly be on 5 because of angle threshold and numeric errors.

although we could try to include the floating point epsilon in the float range contains comparisons, the step value error could still be larger than epsilon depending on the threshold used

thestonefox commented 2 years ago

There's actually a test in the FloatRange that proves it works, so i think it may be something in the drive. I'm going to close this because its not a zinnia problem.