src/util/pointProjector.js
/**
 * Gets the line of intersection between two planes in patient space.
 * @export @public @method
 * @name planePlaneIntersection
 *
 * @param  {Object} targetImagePlane    The target plane.
 * @param  {Object} referenceImagePlane The reference plane
 * @returns {Object}                   The intersections.
 */
Gets the line of intersection between two planes in patient space.
@export @public @method
@name planePlaneIntersection

@param  {Object} targetImagePlane    The target plane.
@param  {Object} referenceImagePlane The reference plane
@returns {Object}                   The intersections.
Gets the line of intersection between two planes in patient space . @export @public @method @name planePlaneIntersection @param { Object } targetImagePlane The target plane . @param { Object } referenceImagePlane The reference plane @returns { Object } The intersections .
function planePlaneIntersection(targetImagePlane, referenceImagePlane) {
  const targetRowCosines = convertToVector3(targetImagePlane.rowCosines);
  const targetColumnCosines = convertToVector3(targetImagePlane.columnCosines);
  const targetImagePositionPatient = convertToVector3(
    targetImagePlane.imagePositionPatient
  );
  const referenceRowCosines = convertToVector3(referenceImagePlane.rowCosines);
  const referenceColumnCosines = convertToVector3(
    referenceImagePlane.columnCosines
  );
  const referenceImagePositionPatient = convertToVector3(
    referenceImagePlane.imagePositionPatient
  );
  const targetNormal = targetRowCosines.clone().cross(targetColumnCosines);
  const targetPlane = new external.cornerstoneMath.Plane();
  targetPlane.setFromNormalAndCoplanarPoint(
    targetNormal,
    targetImagePositionPatient
  );
  const referenceNormal = referenceRowCosines
    .clone()
    .cross(referenceColumnCosines);
  const referencePlane = new external.cornerstoneMath.Plane();
  referencePlane.setFromNormalAndCoplanarPoint(
    referenceNormal,
    referenceImagePositionPatient
  );
  const originDirection = referencePlane.clone().intersectPlane(targetPlane);
  const origin = originDirection.origin;
  const direction = originDirection.direction;
  const bottomRight = imagePointToPatientPoint(
    {
      x: referenceImagePlane.columns,
      y: referenceImagePlane.rows,
    },
    referenceImagePlane
  );
  const distance = referenceImagePositionPatient.distanceTo(bottomRight);
  const line = new external.cornerstoneMath.Line3();
  line.start = origin;
  line.end = origin.clone().add(direction.multiplyScalar(distance));
  const rect = getRectangleFromImagePlane(referenceImagePlane);
  const intersections = lineRectangleIntersection(line, rect);
  if (intersections.length !== 2) {
    return;
  }
  return {
    start: intersections[0],
    end: intersections[1],
  };
}
function planePlaneIntersection ( targetImagePlane , referenceImagePlane ) { const targetRowCosines = convertToVector3 ( targetImagePlane . rowCosines ) ; const targetColumnCosines = convertToVector3 ( targetImagePlane . columnCosines ) ; const targetImagePositionPatient = convertToVector3 ( targetImagePlane . imagePositionPatient ) ; const referenceRowCosines = convertToVector3 ( referenceImagePlane . rowCosines ) ; const referenceColumnCosines = convertToVector3 ( referenceImagePlane . columnCosines ) ; const referenceImagePositionPatient = convertToVector3 ( referenceImagePlane . imagePositionPatient ) ; const targetNormal = targetRowCosines . clone ( ) . cross ( targetColumnCosines ) ; const targetPlane = new external . cornerstoneMath . Plane ( ) ; targetPlane . setFromNormalAndCoplanarPoint ( targetNormal , targetImagePositionPatient ) ; const referenceNormal = referenceRowCosines . clone ( ) . cross ( referenceColumnCosines ) ; const referencePlane = new external . cornerstoneMath . Plane ( ) ; referencePlane . setFromNormalAndCoplanarPoint ( referenceNormal , referenceImagePositionPatient ) ; const originDirection = referencePlane . clone ( ) . intersectPlane ( targetPlane ) ; const origin = originDirection . origin ; const direction = originDirection . direction ; const bottomRight = imagePointToPatientPoint ( { x : referenceImagePlane . columns , y : referenceImagePlane . rows , } , referenceImagePlane ) ; const distance = referenceImagePositionPatient . distanceTo ( bottomRight ) ; const line = new external . cornerstoneMath . Line3 ( ) ; line . start = origin ; line . end = origin . clone ( ) . add ( direction . multiplyScalar ( distance ) ) ; const rect = getRectangleFromImagePlane ( referenceImagePlane ) ; const intersections = lineRectangleIntersection ( line , rect ) ; if ( intersections . length !== 2 ) { return ; } return { start : intersections [ 0 ] , end : intersections [ 1 ] , } ; }
Gets the line of intersection between two planes in patient space.
Gets the line of intersection between two planes in patient space .
// First, get the normals of each image plane // Calculate the longest possible length in the reference image plane (the length of the diagonal) // Use this distance to bound the ray intersecting the two planes // Find the intersections between this line and the reference image plane's four sides // Return the intersections between this line and the reference image plane's sides // In order to draw the reference line from the target image.