FieldSample

What a field sample carries: the direction away from the source (rhat), the strength, and the line angle phi in radians.

FieldSample(props: { rhat: v2f; strength: number; phi: number; }): { rhat: v2f; strength: number; phi: number; }

Import sim from shaders/std and use sim.agentForces.FieldSample.

Build one when writing your own AgentFieldAt.

Parameters

NameTypeNotes
props{ rhat: v2f; strength: number; phi: number; }

Example

return FieldSample({rhat, strength: fieldStr, phi: std.atan2(B.y, B.x)})

See also

  • field.dipoleOrRadial — The field of a magnet at the cursor: a bar magnet along its travel, or a single pole.
  • torque — The turns an agent that spins in place can feel, for integrator.orientation2d.