Parameters
| Name | Type | Description |
|---|---|---|
| position | vec3<f32> | 3D position to transform. |
| angles | vec3<f32> | Rotation angles in radians (x, y, z). |
| pivot | vec3<f32> | Point to rotate around. |
Returns
vec3<f32>position.
WGSL Code
fn sdfRotate(position: vec3<f32>, angles: vec3<f32>, pivot: vec3<f32>) -> vec3<f32> { // First translate to origin relative to pivot point let centered = position - pivot; // Create rotation matrices (inverse rotation = negative angles) let cx = cos(-angles.x); let sx = sin(-angles.x); let cy = cos(-angles.y); let sy = sin(-angles.y); let cz = cos(-angles.z); let sz = sin(-angles.z); // Rotate around X axis let rx = vec3<f32>( centered.x, centered.y * cx - centered.z * sx, centered.y * sx + centered.z * cx ); // Rotate around Y axis let ry = vec3<f32>( rx.x * cy + rx.z * sy, rx.y, -rx.x * sy + rx.z * cy ); // Rotate around Z axis let rz = vec3<f32>( ry.x * cz - ry.y * sz, ry.x * sz + ry.y * cz, ry.z ); // Translate back from pivot point return rz + pivot; }