Skip to content

isCloseTo

const isCloseTo: DualFn<<T>(lhs, rhs, precision) => boolean>

Defined in: packages/typegpu/src/std/boolean.ts:254

Checks whether the given elements differ by at most the precision value. Checks all elements of lhs and rhs if arguments are vectors.

isCloseTo(0, 0.1) // returns false
isCloseTo(vec3f(0, 0, 0), vec3f(0.002, -0.009, 0)) // returns true

argument that specifies the maximum allowed difference, 0.01 by default.