graphics/graphics-utils.js

  1. 'use strict';
  2. /**
  3. * Get the distance between two points, (x1, y1) and (x2, y2)
  4. * @param {number} x1
  5. * @param {number} y1
  6. * @param {number} x2
  7. * @param {number} y2
  8. * @returns {number} Distance between the two points.
  9. */
  10. var getDistance = function(x1, y1, x2, y2) {
  11. return Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
  12. };
  13. module.exports = {
  14. getDistance: getDistance,
  15. };