src/tools/annotation/bidirectionalTool/moveHandle/movePerpendicularLine/movePerpendicularLine.js
/**
 * Move the perpendicular line updating the opposite handle position.
 *
 * @param {*} proposedPoint Point that was moved in bidirectional tool
 * @param {*} measurementData Data from current bidirectional tool measurement
 * @param {*} eventData Data object associated with the event
 * @param {*} fixedPoint Point that is not being moved in long line
 *
 * @returns {boolean} True if perpendicular handles were updated, false if not
 */
Move the perpendicular line updating the opposite handle position.
@param {*} proposedPoint Point that was moved in bidirectional tool
@param {*} measurementData Data from current bidirectional tool measurement
@param {*} eventData Data object associated with the event
@param {*} fixedPoint Point that is not being moved in long line

@returns {boolean} True if perpendicular handles were updated, false if not
Move the perpendicular line updating the opposite handle position . @param { * } proposedPoint Point that was moved in bidirectional tool @param { * } measurementData Data from current bidirectional tool measurement @param { * } eventData Data object associated with the event @param { * } fixedPoint Point that is not being moved in long line @returns { boolean } True if perpendicular handles were updated false if not
function movePerpendicularLine(
  proposedPoint,
  measurementData,
  eventData,
  fixedPoint
) {
  const { lineSegment } = external.cornerstoneMath;
  const baseData = getBaseData(measurementData, eventData, fixedPoint);
  const {
    columnPixelSpacing,
    rowPixelSpacing,
    start,
    longLine,
    intersection,
  } = baseData;
  if (!lineHasLength(columnPixelSpacing, rowPixelSpacing, longLine)) {
    return false;
  }
  const vector = getLineVector(
    columnPixelSpacing,
    rowPixelSpacing,
    start,
    intersection
  );
  const helperLine = getHelperLine(baseData, proposedPoint, vector);
  const newIntersection = lineSegment.intersectLine(longLine, helperLine);
  if (!newIntersection) {
    return false;
  }
  const newLine = updatePerpendicularLine(
    baseData,
    newIntersection,
    helperLine,
    vector
  );
  measurementData.handles.perpendicularStart.x = newLine.start.x;
  measurementData.handles.perpendicularStart.y = newLine.start.y;
  measurementData.handles.perpendicularEnd.x = newLine.end.x;
  measurementData.handles.perpendicularEnd.y = newLine.end.y;
  return true;
}
function movePerpendicularLine ( proposedPoint , measurementData , eventData , fixedPoint ) { const { lineSegment } = external . cornerstoneMath ; const baseData = getBaseData ( measurementData , eventData , fixedPoint ) ; const { columnPixelSpacing , rowPixelSpacing , start , longLine , intersection , } = baseData ; if ( ! lineHasLength ( columnPixelSpacing , rowPixelSpacing , longLine ) ) { return false ; } const vector = getLineVector ( columnPixelSpacing , rowPixelSpacing , start , intersection ) ; const helperLine = getHelperLine ( baseData , proposedPoint , vector ) ; const newIntersection = lineSegment . intersectLine ( longLine , helperLine ) ; if ( ! newIntersection ) { return false ; } const newLine = updatePerpendicularLine ( baseData , newIntersection , helperLine , vector ) ; measurementData . handles . perpendicularStart . x = newLine . start . x ; measurementData . handles . perpendicularStart . y = newLine . start . y ; measurementData . handles . perpendicularEnd . x = newLine . end . x ; measurementData . handles . perpendicularEnd . y = newLine . end . y ; return true ; }
Move the perpendicular line updating the opposite handle position.
Move the perpendicular line updating the opposite handle position .
// Stop here if the long line has no length // Inclination of the perpendicular line // Get a helper line to calculate the intersection // Find the new intersection in the long line // Stop the flow here if there's no intersection point between lines // Calculate and the new position of the perpendicular handles // Change the position of the perpendicular line handles