@bnidev/js-utils
    Preparing search index...

    Function distance

    • Calculates the Euclidean distance between two points in a 2D space.

      Parameters

      • x1: number

        The x-coordinate of the first point.

      • y1: number

        The y-coordinate of the first point.

      • x2: number

        The x-coordinate of the second point.

      • y2: number

        The y-coordinate of the second point.

      Returns number

      The distance between the two points.

      // ES Module
      import { distance } from '@bnidev/js-utils'

      // CommonJS
      const { distance } = require('@bnidev/js-utils')
      const dist = distance(0, 0, 3, 4) // dist will be 5