Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0
// getHorizontalDistance.js
/* global AdventureJS A */

/**
 * Calculate the distance between the x/z of two points.
 * @method AdventureJS#getHorizontalDistance
 * @memberOf AdventureJS
 * @param {Object} point1
 * @param {Object} point2
 * @returns {Float}
 */
AdventureJS.FX.getHorizontalDistance =
  function AdventureJS_getHorizontalDistance(point1, point2) {
    const deltaX = point2.x - point1.x;
    const deltaZ = point2.z - point1.z;

    return Math.sqrt(deltaX * deltaX + deltaZ * deltaZ);
  };