src/tools/segmentation/SphericalBrushTool.js
/**
   * _getRadiusOnImage - If the image is in range of the spherical brush, returns
   *                     the in-plane brush radius on that image.
   *
   * @param  {string} imageId           The cornerstone imageId of the image.
   * @param  {number[]} ippOfCurrentImage The image position patient of the current image.
   * @param  {number} radiusInMM        The radius of the sphere in millimeters.
   * @param  {string} pixelSpacing      The pixelspacing.
   * @returns {number|undefined}        The brush radius on the image, undefined if
   *                                    the image is out of range of the sphere.
   */
If the image is in range of the spherical brush, returns
the in-plane brush radius on that image.

@param  {string} imageId           The cornerstone imageId of the image.
@param  {number[]} ippOfCurrentImage The image position patient of the current image.
@param  {number} radiusInMM        The radius of the sphere in millimeters.
@param  {string} pixelSpacing      The pixelspacing.
@returns {number|undefined}        The brush radius on the image, undefined if
the image is out of range of the sphere.
If the image is in range of the spherical brush returns the in - plane brush radius on that image . @param { string } imageId The cornerstone imageId of the image . @param { number [] } ippOfCurrentImage The image position patient of the current image . @param { number } radiusInMM The radius of the sphere in millimeters . @param { string } pixelSpacing The pixelspacing . @returns { number|undefined } The brush radius on the image undefined if the image is out of range of the sphere .
_getRadiusOnImage(imageId, ippOfCurrentImage, radiusInMM, pixelSpacing) {
    const imagePlane = external.cornerstone.metaData.get(
      'imagePlaneModule',
      imageId
    );
    if (!imagePlane) {
      logger.warn(
        `Can't find imagePlane metadata for image, cancelling spherical brushing on: ${imageId},`
      );
      return;
    }
    const ipp = imagePlane.imagePositionPatient;
    const distance = Math.sqrt(
      Math.pow(ipp[0] - ippOfCurrentImage[0], 2) +
        Math.pow(ipp[1] - ippOfCurrentImage[1], 2) +
        Math.pow(ipp[2] - ippOfCurrentImage[2], 2)
    );
    if (distance > radiusInMM) {
      return;
    }
    return Math.floor(
      Math.sqrt(Math.pow(radiusInMM, 2) - Math.pow(distance, 2)) / pixelSpacing
    );
  }
_getRadiusOnImage ( imageId , ippOfCurrentImage , radiusInMM , pixelSpacing ) { const imagePlane = external . cornerstone . metaData . get ( 'imagePlaneModule' , imageId ) ; if ( ! imagePlane ) { logger . warn ( ` ${ imageId } ` ) ; return ; } const ipp = imagePlane . imagePositionPatient ; const distance = Math . sqrt ( Math . pow ( ipp [ 0 ] - ippOfCurrentImage [ 0 ] , 2 ) + Math . pow ( ipp [ 1 ] - ippOfCurrentImage [ 1 ] , 2 ) + Math . pow ( ipp [ 2 ] - ippOfCurrentImage [ 2 ] , 2 ) ) ; if ( distance > radiusInMM ) { return ; } return Math . floor ( Math . sqrt ( Math . pow ( radiusInMM , 2 ) - Math . pow ( distance , 2 ) ) / pixelSpacing ) ; }
_getRadiusOnImage - If the image is in range of the spherical brush, returns
                     the in-plane brush radius on that image.
_getRadiusOnImage - If the image is in range of the spherical brush returns the in - plane brush radius on that image .
// Image too far away, break!