I have 1 value for example 3.39945
How can test if value approximately equal to 4.4?
And test if vector3(14,3.39945,0) approximately equal to vector3(14,4.4,0) or not.
I have 1 value for example 3.39945
How can test if value approximately equal to 4.4?
And test if vector3(14,3.39945,0) approximately equal to vector3(14,4.4,0) or not.
//C#
static bool RoughlyEqual(float a, float b) {
float treshold = 2f; //how much roughly
return (Math.Abs(a-b)< treshold);
}
and about vectors comparison:
Thanks!!!
Working fine, if value approximately equal to +0.02,-0.02 = 1 then valu = true.
var valuee : float;
var valu : boolean;
function Update() {
valu = Mathf.Abs(valuee-1) < 0.02;
}