javamathvectordicomequations

how to calculate plane equation using three points and two vectors?


I am trying to calculate two plane equations from the data of two dicom images and get an intersection line from these two plane equations. The dicom tag ImagePositionPatient has three coordinates x,y,z and the tag ImageOrientationPatient has two vectors each with three components. How equation of plane can be calculated using these three coordinates and two vectors?

This is my code:

public void ShowLocalizerLine(View v)
{
    //Getting The Values
    InfoOfFirst();  //This gets the img position and orientation of src img
    InfoOfSecond(); //This gets the img position and orientation of dst img
    String[] src_position_array = new String[3];
    src_position_array = firstimg_position.split("\\\\");
    Src_Position_Xo = Float.parseFloat(src_position_array[0]);
    Src_Position_Yo = Float.parseFloat(src_position_array[1]);
    Src_Position_Zo = Float.parseFloat(src_position_array[2]);

    String[] src_orientation_array = new String[6];
    src_orientation_array = firstimg_orientation.split("\\\\");
    Src_Orientation_Vector1_A = Float.parseFloat(src_orientation_array[0]);
    Src_Orientation_Vector1_B = Float.parseFloat(src_orientation_array[1]);
    Src_Orientation_Vector1_C = Float.parseFloat(src_orientation_array[2]);
    Src_Orientation_Vector2_D = Float.parseFloat(src_orientation_array[3]);
    Src_Orientation_Vector2_E = Float.parseFloat(src_orientation_array[4]);
    Src_Orientation_Vector2_F = Float.parseFloat(src_orientation_array[5]);

    String[] dst_position_array = new String[3];
    dst_position_array = secimg_position.split("\\\\");
    Dst_Position_Xo = Float.parseFloat(dst_position_array[0]);
    Dst_Position_Yo = Float.parseFloat(dst_position_array[1]);
    Dst_Position_Zo = Float.parseFloat(dst_position_array[2]);

    String[] dst_orientation_array = new String[6];
    dst_orientation_array = secimg_orientation.split("\\\\");
    Dst_Orientation_Vector1_A = Float.parseFloat(dst_orientation_array[0]);
    Dst_Orientation_Vector1_B = Float.parseFloat(dst_orientation_array[1]);
    Dst_Orientation_Vector1_C = Float.parseFloat(dst_orientation_array[2]);
    Dst_Orientation_Vector2_D = Float.parseFloat(dst_orientation_array[3]);
    Dst_Orientation_Vector2_E = Float.parseFloat(dst_orientation_array[4]);
    Dst_Orientation_Vector2_F = Float.parseFloat(dst_orientation_array[5]);

    //Calculations
    float dst_nrm_dircos_x = Dst_Orientation_Vector1_B*Dst_Orientation_Vector2_F - Dst_Orientation_Vector1_C*Dst_Orientation_Vector2_E;
    float dst_nrm_dircos_y = Dst_Orientation_Vector1_C*Dst_Orientation_Vector2_D - Dst_Orientation_Vector1_A*Dst_Orientation_Vector2_F;
    float dst_nrm_dircos_z = Dst_Orientation_Vector1_A*Dst_Orientation_Vector2_E - Dst_Orientation_Vector1_B*Dst_Orientation_Vector2_D;

    float src_pos_x = Src_Position_Xo - Dst_Position_Xo;
    float src_pos_y = Src_Position_Yo - Dst_Position_Yo;
    float src_pos_z = Src_Position_Zo - Dst_Position_Zo;
    float dst_pos_x = Dst_Orientation_Vector1_A*src_pos_x + Dst_Orientation_Vector1_B*src_pos_y + Dst_Orientation_Vector1_C*src_pos_z;
    float dst_pos_y = Dst_Orientation_Vector2_D*src_pos_x + Dst_Orientation_Vector2_E*src_pos_y + Dst_Orientation_Vector2_F*src_pos_z;
    float dst_pos_z = dst_nrm_dircos_x*src_pos_x + dst_nrm_dircos_y*src_pos_y + dst_nrm_dircos_z*src_pos_z;     
}

Solution

  • From the class names I guess ImagePositionPatient gives a point (say a) on the plane and ImageOrientationPatient (say n) gives the normal. (I wouldn't know this is correct but since you told me they are 3D vectors this is what I have in mind).

    Then your plane equation is given by dot(n, a) = dot(n, x), where x is the position variable and n is normalized. This gives Ax + By + Cz = D which is the Cartesian equation.