Hi,
I'm trying to compare 3 points but because of double precision in AS3
i'm running into some issues with trailing digits causing the numbers
to not be equal, i.e. 1.25 != 1.24999
what i'd like to figure out how to do is introduce a tolerance of say
.001. then i'd compare the test point
If you want to know to compare two values with tolerance then subtract them
and see if the result is within your tolerance.
public function within(x:Number, y:Number, tolerance:Number):Boolean {
var difference:Number = x - y;
return difference <= tolerance && difference >= - tollerance;
}
HTH
2 matches
Mail list logo