AlgoSim
Homepage | Screenshots | Gallery of Visualisation | User's Guide | Function Reference | Download | FAQ | Support | Bugs and Solutions | Donate

Reference: drawVectorField

drawVectorField(s) draws the vector field s, a string representing the valid identifier of a vector field set, i.e. a set of vectors (x, y, vx, vy) associating a vector (vx(x, y), vy(x, y)) to each point (x, y) of the plane. Such sets are easily generated from any vector-valued expression using the function createVectorField.

drawVectorField(s, fmt) uses the format (CSS) fmt.

Examples: Vertical constant vector field (e.g. gravity):
          gravity ≔ createVectorField("❨0, -1❩", "x, y", [-10, 10]^2)
          drawVectorField("gravity", "colour:#333333")

          Horizontal linear vector field (e.g. a spring force)
          force ≔ createVectorField("❨-x, 0❩", "x, y", [-10, 10]^2)
          drawVectorField("force", "colour:#333333")

          An oscillating chemical reaction
          a ≔ 2
          b ≔ 3.001

          vectorField ≔ createVectorField("❨1 + a⋅x^2⋅y − b⋅x−x, -a⋅x^2⋅y + b⋅x❩", "x, y", [0, 10, 0.25]^2)
          drawVectorField("vectorField", "colour:#333333")

          flow ≔ computeFlowTrajectory("❨1 + a⋅r_1^2⋅r_2 − b⋅r_1 − r_1, -a⋅r_1^2⋅r_2 + b⋅r_1❩", "r", ❨1, 4❩, 0, 100, 0.01)
          drawLines("flow", "colour:gold")