Skip to content

math.mat4.norm

Summary

math.mat4.norm returns the Frobenius norm of a 4x4 matrix: the square root of the sum of its 16 squared components.

Syntax

WasmGPU.math.mat4.norm(matr: number[]): number
const result = wgpu.math.mat4.norm(matr);

Precision-Specific Wasm Forms

WasmGPU.math.mat4f.norm(m: WasmPtr): number
WasmGPU.math.mat4d.norm(m: WasmPtr): number

These forms use caller-owned pointers to 16-element matrix blocks in WasmGPU driver memory: binary32 for mat4f and binary64 for mat4d. Methods with an output pointer write that block instead of allocating a JavaScript array. See WasmGPU.math for allocation, views, aliasing, and release requirements.

Parameters

Name Type Required Description
matr number[] Yes Column-major 4x4 matrix whose Frobenius norm is returned.

Returns

number - Euclidean norm (magnitude) of the input.

Type Details

type Mat4 = number[]; // expected length: 16 (4x4, column-major)

Example

const canvas = document.querySelector("canvas");
const wgpu = await WasmGPU.create(canvas);

const matr = wgpu.math.mat4.translate(wgpu.math.mat4.identity(), [1, 2, 3]);
const result = wgpu.math.mat4.norm(matr);
console.log(result);

See Also