You probably want to change this to Math.abs(dot(vector)) <= epsilon. The same applies for the one with fixed epsilon and the methods in Vector2.