/**
* Compares left
and right
componentwise. Returns true
* if they are within epsilon
and false
otherwise. The inputs
* left
and right
can be float
s, vec2
s,
* vec3
s, or vec4
s.
*
* @name czm_equalsEpsilon
* @glslFunction
*
* @param {} left The first vector.
* @param {} right The second vector.
* @param {float} epsilon The epsilon to use for equality testing.
* @returns {bool} true
if the components are within epsilon
and false
otherwise.
*
* @example
* // GLSL declarations
* bool czm_equalsEpsilon(float left, float right, float epsilon);
* bool czm_equalsEpsilon(vec2 left, vec2 right, float epsilon);
* bool czm_equalsEpsilon(vec3 left, vec3 right, float epsilon);
* bool czm_equalsEpsilon(vec4 left, vec4 right, float epsilon);
*/
bool czm_equalsEpsilon(vec4 left, vec4 right, float epsilon) {
return all(lessThanEqual(abs(left - right), vec4(epsilon)));
}
bool czm_equalsEpsilon(vec3 left, vec3 right, float epsilon) {
return all(lessThanEqual(abs(left - right), vec3(epsilon)));
}
bool czm_equalsEpsilon(vec2 left, vec2 right, float epsilon) {
return all(lessThanEqual(abs(left - right), vec2(epsilon)));
}
bool czm_equalsEpsilon(float left, float right, float epsilon) {
return (abs(left - right) <= epsilon);
}