distance
On this page

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'

The signature, the description and the examples come from the compiler's own source at commit 26de7be8.

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

a ReadonlyNode<K>
b NoInfer<ReadonlyNode<K>>

Return value

Node<'f64'>

Description

Returns f32 for f32 vectors and f64 for emulated-double vectors.

Targets

TargetSupportNotes
WGSL (WebGPU) Supported

distance(a, b). Over f64 operands the fp64 pass rewrites it into its df64 helper.

GLSL ES 3.00 (WebGL2) Supported

distance(a, b). Over f64 operands the fp64 pass rewrites it into its df64 helper.

CPU oracle Supported

Evaluated in f64 by the oracle.

In the guide

Source

src/core/ir/node.ts, line 1853, at commit 26de7be8

Edit this page Report a problem