Documentation
    Preparing search index...

    Function vortexField

    • §27's vortex: a purely tangential swirl around the line through center along axis.

      â       = axis / |axis|                     (normalized at construction)
      r       = position − center
      r∥      = (r · â) â                         (component along the axis)
      r⊥      = r − r∥,   d = |r⊥|                (distance from the axis)
      t       = â × r     = â × r⊥,   |t| = d
      a       = strength · (t / d) / max(d, minDistance)
      

      so the magnitude is |strength| / max(d, minDistance) — inverse-distance, one power gentler than radialField — and the direction is â × r̂⊥, a unit vector perpendicular to both the axis and r. Two properties follow exactly (both pinned by the tests):

      • a · â = 0 — nothing is pushed along the axis;
      • a · r = 0 — no radial component, so a vortex alone neither sucks particles in nor throws them out. Pair it with radialField for an inward spiral; that separation is the reason the two are distinct fields.

      Handedness follows the right-hand rule: with axis = +Y, a particle at +X is pushed toward −Z (ŷ × x̂ = −ẑ), i.e. counter-clockwise when viewed from +Y looking down at the XZ plane in a right-handed Y-up world (§7a). Negate strength to reverse it.

      On the axis (d === 0) the tangent is undefined, so the field contributes (0, 0, 0).

      Parameters

      • center: Vector3

        A point on the vortex axis, copied.

      • axis: Vector3

        Axis direction, copied and normalized. Need not be unit length.

      • strength: number

        Signed tangential strength in units²/s².

      • Optionaloptions: VortexFieldOptions

      Returns ParticleForceField

      RangeError if any component of center or axis, or strength, or options.minDistance, is not finite; if minDistance <= 0; or if axis has zero length (unlike a cone direction, a vortex has no sensible default axis).