src/util/freehand/FreehandLineFinder.js
/**
   * Calculates the perpendicular distance of the mouse cursor from a line segment.
   * @private
   * @method
   *
   * @param {FreehandHandleData} handle1 The first handle.
   * @param {FreehandHandleData} handle2 The first handle.
   * @returns {number} The perpendicular distance of the mouse cursor from the line segment.
   */
Calculates the perpendicular distance of the mouse cursor from a line segment.
@private
@method

@param {FreehandHandleData} handle1 The first handle.
@param {FreehandHandleData} handle2 The first handle.
@returns {number} The perpendicular distance of the mouse cursor from the line segment.
Calculates the perpendicular distance of the mouse cursor from a line segment . @private @method @param { FreehandHandleData } handle1 The first handle . @param { FreehandHandleData } handle2 The first handle . @returns { number } The perpendicular distance of the mouse cursor from the line segment .
_distanceOfPointfromLine(handle1, handle2) {
    const eventData = this._eventData;
    const p1 = external.cornerstone.pixelToCanvas(eventData.element, handle1);
    const p2 = external.cornerstone.pixelToCanvas(eventData.element, handle2);
    const pMouse = this._mousePoint;
    const twiceAreaOfTriangle = Math.abs(
      (p2.y - p1.y) * pMouse.x -
        (p2.x - p1.x) * pMouse.y +
        p2.x * p1.y -
        p2.y * p1.x
    );
    const rMagnitude = external.cornerstoneMath.point.distance(p1, p2);
    const d = twiceAreaOfTriangle / rMagnitude;
    return d;
  }
_distanceOfPointfromLine ( handle1 , handle2 ) { const eventData = this . _eventData ; const p1 = external . cornerstone . pixelToCanvas ( eventData . element , handle1 ) ; const p2 = external . cornerstone . pixelToCanvas ( eventData . element , handle2 ) ; const pMouse = this . _mousePoint ; const twiceAreaOfTriangle = Math . abs ( ( p2 . y - p1 . y ) * pMouse . x - ( p2 . x - p1 . x ) * pMouse . y + p2 . x * p1 . y - p2 . y * p1 . x ) ; const rMagnitude = external . cornerstoneMath . point . distance ( p1 , p2 ) ; const d = twiceAreaOfTriangle / rMagnitude ; return d ; }
Calculates the perpendicular distance of the mouse cursor from a line segment.
Calculates the perpendicular distance of the mouse cursor from a line segment .
// Perpendicular distance of point from line: // = 2* area of triangle(p1,p2,pm) / length of triangle's base |p2 - p1|