Parameters
| Name | Type | Description |
|---|---|---|
| position | vec3<f32> | 3D position to transform. |
| count | f32 | Number of repetitions around the circle. |
| axis | vec3<f32> | Axis to repeat around (should be normalized). |
Returns
vec3<f32>repeated position.
WGSL Code
fn sdfPolarRepeat(position: vec3<f32>, count: f32, axis: vec3<f32>) -> vec3<f32> { let n = normalize(axis); // Project position onto axis let axisProj = dot(position, n) * n; let radial = position - axisProj; // Get angle in the plane perpendicular to axis let radius = length(radial); if (radius < 0.001) { return position; } let angle = atan2(radial.y, radial.x); let sectorAngle = 6.28318530718 / count; let snappedAngle = round(angle / sectorAngle) * sectorAngle; // Reconstruct position with snapped angle let newRadial = radius * vec2<f32>(cos(snappedAngle), sin(snappedAngle)); // This assumes axis is along Z - for general axis, need proper basis vectors return axisProj + vec3<f32>(newRadial.x, newRadial.y, 0.0); }