distance()
Function in Builtins
distance(a, b): |a − b|, vector to scalar; the built-in form of length(a.sub(b)).
import { distance } from 'typeshade/core/ir'
This export returns an IR node. A "use typeshade" file calls the builtin itself: distance()
The signature, the description and the examples come from the compiler's own source at commit af54ddad5.
Syntax
function distance<K extends `vec${number}<f64>`>( a: ReadonlyNode<K>, b: NoInfer<ReadonlyNode<K>>,): Node<'f64'>;function distance<K extends `vec${number}<f32>`>( a: ReadonlyNode<K>, b: NoInfer<ReadonlyNode<K>>,): Node<'f32'>;Parameters
aReadonlyNode<K>bNoInfer<ReadonlyNode<K>>
Return value
Node<'f64'>
Description
Returns f32 for f32 vectors and f64 for emulated-double vectors.
Targets
| Target | Support | Notes |
|---|---|---|
| WGSL (WebGPU) | Supported |
|
| GLSL ES 3.00 (WebGL2) | Supported |
|
| CPU oracle | Supported | Evaluated in |
In the guide
See also
Source
src/core/ir/node.ts, line 1614, at commit af54ddad5