I have question about Equal Vector and Tolerance.
Tolerance - what is it? I know from UE tips what tolerance is “…a specified error…”, but what does it really mean? How can I calculate it by manual?
I don’t understand why I have different results (if I correct copy/paste log):
Equal vectors is True
X=0.000 Y=1.000 Z=0.000
X=0.293 Y=0.858 Z=0.421
Equal vectors is False
X=0.000 Y=1.000 Z=0.000
X=-0.411 Y=0.359 Z=0.838
Tolerance in both cases is 0.7.
I can not find info in manual? If you can find info, please send link me.
Hi, not sure how much you know about the floats so I’ll start from the basics.
Because of how float variables are stored in computer memory there is a really high chance that 2 float variables declared as 0.7 won’t actually be 0.7000(…) but for example 0.70001 and 0.6999, and that makes default comparison operator unreliable (to say the least). To make that bearable ;D people got an idea that they will check the range instead of 1 value comparison. For example if the variable is somewhere between 6.9f and 7.1f and you’re using 0.7f as base, that would make it a tolerance of 0.1
Having that in mind the vector is just a struct with 3 float so the same rules apply. Here is the code the vector’s Equals() method use:
As you can see it takes absolute of the difference between the vector you’re calling method on and the checking(?) vector, then checks whether that value is <= your tolerance.
Oh and going back to your example, the one when the method returns false, the difference between Z values is higher than 0.7 that’s why this returns false.