Skip to content

WasmGPU.math.quat.abs

Summary

WasmGPU.math.quat.abs returns the component-wise absolute value of the input. Use it to remove sign from each component without changing magnitude ordering.

Syntax

WasmGPU.math.quat.abs(q: number[]): number[]
const result = wgpu.math.quat.abs(q);

Parameters

Name Type Required Description
q number[] Yes Quaternion input as [x, y, z, w].

Returns

number[] - New quaternion as [x, y, z, w].

Type Details

type Quat = number[]; // expected length: 4 ([x, y, z, w])

Example

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

const q = [0, Math.sin(Math.PI / 8), 0, Math.cos(Math.PI / 8)];
const result = wgpu.math.quat.abs(q);
console.log(result);

See Also