dot
On this page

dot

Function

Returns the dot product of two vectors: the sum of products of corresponding components.

The signature and the sentence under each name are the compiler's own text at commit 26de7be8.

Syntax

declare function dot<V extends vec2 | vec3 | vec4 | vec2i | vec3i | vec4i | vec2u | vec3u | vec4u>(a0: V, a1: V): (V extends { readonly [vecTag]: readonly ['f32', number] } ? f32 : V extends { readonly [vecTag]: readonly ['i32', number] } ? i32 : u32)
declare function dot<T extends Numeric | Vec64Any>(a0: T, a1: T): T extends Vec64Any ? f64 : number

A number in a parameter or a return position is the scalar slot. The ambient file declares a GPU scalar as a branded number whose brand is optional, so a literal and any branded scalar both fill it.

type f32 = number & { readonly [f32Tag]?: true }

A declaration you write still needs a width, and a bare number on a field or a parameter is refused; the TypeScript constructs page carries that row with the compiler's own message.

A signature may name a type the ambient file declares for its own use. These are those declarations.

Vec64Any
type Vec64Any = vec2f64 | vec3f64 | vec4f64
Numeric
type Numeric = number | vec2 | vec3 | vec4 | vec2i | vec3i | vec4i | vec2u | vec3u | vec4u

Parameters

A parameter named by position (a0, a1) carries a name the ambient file generates. A call passes its arguments in order and names none of them.

  • a0 VT
  • a1 VT

Return value

(V extends { readonly [vecTag]: readonly ['f32', number] } ? f32 : V extends { readonly [vecTag]: readonly ['i32', number] } ? i32 : u32)T extends Vec64Any ? f64 : number

Description

Reduces a vector to a scalar.

Targets

WGSL
dot(a, b)
GLSL ES 3.00
dot(a, b)

Examples

See also

Edit this page Report a problem