WasmGPU.math.quat.round¶
Summary¶
WasmGPU.math.quat.round rounds each component to the nearest integer. It is useful when snapping values to a grid or discrete representation.
Syntax¶
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¶
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.round(q);
console.log(result);