curl: Vector Field Flow Analysis
Advanced Flow Pattern Generation Through Differential Calculus
The curl function computes the rotational characteristics of vector fields generated from noise functions. This mathematical operator calculates the circulation density at each point in a field, creating natural swirling and turbulent patterns essential for fluid dynamics simulation.
Mathematical Foundation
For a 2D vector field , the curl operation is defined as:
For 3D vector fields , the curl becomes:
The implementation uses finite differences with step size to approximate these partial derivatives numerically.
Function Variants
Function | Input Type | Output Type | Purpose |
---|---|---|---|
curlVec2 | vec2 | vec2 | 2D flow field analysis |
curlVec3 | vec3 | vec3 | 3D turbulence patterns |
curlVec4 | vec4 | vec3 | Time-varying flow evolution |
Implementation
ライブエディター
const fragment = () => { const p = uv.mul(4) const flow = curlVec2(p.add(iTime.mul(0.1))) const angle = flow.y.atan2(flow.x).add(float(3.14159)).div(float(3.14159).mul(2)) return vec4(flow, angle, 1) }
ライブエディター
const fragment = () => { const p = vec3(uv.mul(3), iTime.mul(0.2)) const vorticity = curlVec3(p) const magnitude = vorticity.length() const color = vorticity.abs().normalize().mul(magnitude).pow(vec3(0.7)) return vec4(color, 1) }