WasmGPU.math.quat.fromAxisAngle¶
Summary¶
WasmGPU.math.quat.fromAxisAngle builds a quaternion from an axis and a radian angle. It is the standard bridge from geometric axis-angle to quaternion rotation.
Syntax¶
WasmGPU.math.quat.fromAxisAngle(axis: number[], angle: number): number[]
const result = wgpu.math.quat.fromAxisAngle(axis, angle);
Parameters¶
| Name | Type | Required | Description |
|---|---|---|---|
axis |
number[] |
Yes | Rotation axis [x, y, z]; normalize for predictable results. |
angle |
number |
Yes | Rotation angle in radians. |
Returns¶
number[] - New quaternion as [x, y, z, w].
Type Details¶
type Quat = number[]; // expected length: 4 ([x, y, z, w])
type Vec3 = number[]; // expected length: 3 ([x, y, z])
Example¶
const canvas = document.querySelector("canvas");
const wgpu = await WasmGPU.create(canvas);
const axis = [0, 1, 0];
const angle = Math.PI / 4;
const result = wgpu.math.quat.fromAxisAngle(axis, angle);
console.log(result);