Flocc
    Preparing search index...

    Function manhattanDistance

    • Finds the Manhattan distance between p1 and p2.

      The inputs may be plain objects with x, y, and/or z keys, Vectors, or Agents with x, y, and/or z data.

      const a1 = new Agent();
      const a2 = new Agent({ x: 3, y: 4 });
      manhattanDistance(a1, a2); // returns 7 (defaults to x = 0 and y = 0 for a1)

      const p1 = { x: 3, y: 2 };
      const p2 = { x: 0, y: 4 };
      manhattanDistance(p1, p2); // returns 5

      Parameters

      Returns number

      0.0.12