src/tools/annotation/bidirectionalTool/utils/calculateLongestAndShortestDiameters.js
/**
 * Calculates longest and shortest diameters using measurement handles and pixelSpacing
 * @param  {Object} measurementData
 * @param {Object} pixelSpacing pixelSpacing
 *
 *@returns {Object} longestDiameter and shortestDiameter
 */
Calculates longest and shortest diameters using measurement handles and pixelSpacing
@param  {Object} measurementData
@param {Object} pixelSpacing pixelSpacing

@returns {Object} longestDiameter and shortestDiameter
Calculates longest and shortest diameters using measurement handles and pixelSpacing @param { Object } measurementData @param { Object } pixelSpacing pixelSpacing @returns { Object } longestDiameter and shortestDiameter
function calculateLongestAndShortestDiameters(
  measurementData,
  pixelSpacing
) {
  const { rowPixelSpacing, colPixelSpacing } = pixelSpacing;
  const {
    start,
    end,
    perpendicularStart,
    perpendicularEnd,
  } = measurementData.handles;
  const dx = (start.x - end.x) * (colPixelSpacing || 1);
  const dy = (start.y - end.y) * (rowPixelSpacing || 1);
  let length = Math.sqrt(dx * dx + dy * dy);
  const wx =
    (perpendicularStart.x - perpendicularEnd.x) * (colPixelSpacing || 1);
  const wy =
    (perpendicularStart.y - perpendicularEnd.y) * (rowPixelSpacing || 1);
  let width = Math.sqrt(wx * wx + wy * wy);
  if (!width) {
    width = 0;
  }
  if (width > length) {
    const tempW = width;
    const tempL = length;
    length = tempW;
    width = tempL;
  }
  return {
    longestDiameter: length.toFixed(1),
    shortestDiameter: width.toFixed(1),
  };
}
function calculateLongestAndShortestDiameters ( measurementData , pixelSpacing ) { const { rowPixelSpacing , colPixelSpacing } = pixelSpacing ; const { start , end , perpendicularStart , perpendicularEnd , } = measurementData . handles ; const dx = ( start . x - end . x ) * ( colPixelSpacing || 1 ) ; const dy = ( start . y - end . y ) * ( rowPixelSpacing || 1 ) ; let length = Math . sqrt ( dx * dx + dy * dy ) ; const wx = ( perpendicularStart . x - perpendicularEnd . x ) * ( colPixelSpacing || 1 ) ; const wy = ( perpendicularStart . y - perpendicularEnd . y ) * ( rowPixelSpacing || 1 ) ; let width = Math . sqrt ( wx * wx + wy * wy ) ; if ( ! width ) { width = 0 ; } if ( width > length ) { const tempW = width ; const tempL = length ; length = tempW ; width = tempL ; } return { longestDiameter : length . toFixed ( 1 ) , shortestDiameter : width . toFixed ( 1 ) , } ; }
Calculates longest and shortest diameters using measurement handles and pixelSpacing
 @param  {Object} measurementData
 @param {Object} pixelSpacing pixelSpacing
Calculates longest and shortest diameters using measurement handles and pixelSpacing @param { Object } measurementData @param { Object } pixelSpacing pixelSpacing
// Calculate the long axis length // Calculate the short axis length // Length is always longer than width