Skip to content

isCloseTo

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

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

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

T extends number | AnyFloatVecInstance

T

T

number = 0.01

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

boolean

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