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.
Type Parameters
Section titled “Type Parameters”• T extends number
| AnyFloatVecInstance
Parameters
Section titled “Parameters”T
T
precision
Section titled “precision”number
= 0.01
argument that specifies the maximum allowed difference, 0.01 by default.
Returns
Section titled “Returns”boolean
Example
Section titled “Example”isCloseTo(0, 0.1) // returns falseisCloseTo(vec3f(0, 0, 0), vec3f(0.002, -0.009, 0)) // returns true