math docs
    Preparing search index...

    Function curl2

    • Curl of a 2D scalar noise potential - a divergence-free (incompressible) flow field. Particles advected through it swirl like a fluid and never converge to sinks or fly apart, which is why it's the cheap go-to for procedural smoke / flow. Given a scalar potential psi(x, y), the flow is (d psi/dy, -d psi/dx), with the derivatives taken by central differences of step eps.

      Parameters

      • out: vec2.Vec2

        the receiving Vec2 (the flow velocity)

      • sample: (x: number, y: number) => number

        the scalar potential noise, sampled at (x, y)

      • x: number

        x coordinate

      • y: number

        y coordinate

      • eps: number = 1e-4

        finite-difference step (default 1e-4)

      Returns vec2.Vec2

      out