Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

How to Extract 2D Plane Orthogonal to a LINE

1 vue (au cours des 30 derniers jours)
Muhammad Jawaid
Muhammad Jawaid le 25 Mar 2015
Clôturé : John D'Errico le 25 Mar 2015
Hello All, My Question is regarding extracting Plane/Slice of Data from Volume (Orthogonal to a line Passing through TWO Points). AFTER doin all the Vector manipulation, I have plotted LINE, as well as the SURFACE Plane (129*129) that is ORTHOGONAL to the LINE.
No I am stuck with the problem as the ORTHOGONAL PLANE that I have constructed have Coordinates accordingly:
x-coordinates=-64:64; y-coordinates=-64:64; z-coordinates=VALUES OBTAINED through the EQUATION of PLANE.
Now How to MAP these coordinate values to extract data around the given Point P1[5 18 10]. In case of applying simple translation, X and Y axes are mapped correctly, BUT Z coordinate varies and It does not remain the plane we want to access , as Plane must pass through given point P1[5 18 10];
I have tried new_x=old_x+5; new_y=old_y+18; new_z=old_z+10; But this shifts my whole PLANE , as I have already Obtained Z-VALUES for plane through equation of PLANE. ThankYou in Advance...
Kindly help me so that I could proce
clc;clear all; load mri; D=squeeze(D);volume=D;
P1=[5 18 10]; % Point P1, Picked from Skeleton Data P2=[6 19 11]; % Point P2, Picked from Skeleton Data dv_line=[P2(1)-P1(1) P2(2)-P1(2) P2(3)-P1(3)]; % Direction_Vector of Line t=linspace(-10,10); % Vector Equation of Line x=P1(1) +dv_line(1)*t; % X coordinate y=P1(2) +dv_line(2)*t; % Y coordinate z=P1(3) +dv_line(3)*t; % Z coordinate plot3(x,y,z,'LineWidth',2,'Color','r') % Plot LINEfor Validation of results in 3D grid on %LINE PLOTTING fINISHED
hold on pt=[5 18 10]; plot3(pt(1),pt(2),pt(3),'y.','MarkerSize',16)
radius=64 volSz=size(volume) epsilon=1e-12; x=linspace(-radius,radius,2*radius+1); y=linspace(-radius,radius,2*radius+1); z=zeros(2*radius+1); hsp=surf(x,y,z); rotate(hsp,[0 0 1],0) xdO=get(hsp,'XData'); ydO=get(hsp,'YData'); zdO=get(hsp,'ZData');
hold on syms x y z; dv_plane=[x-P1(1) y-P1(2) z-P1(3)] ; % Direction Vector of Plane Obtained with point passing through Plane dot_product=dot(dv_line,dv_plane); % Obtain Dot Product of two Direction Vectors (must be ZERO) z=solve(dot_product,'z'); % Solve Dot Product for Obtaining equation for z x=xdO;y=ydO; % Generate XY Range for Assignment z_value=eval(z);
delete(hsp) hsp2=surf(x,y,z_value);
xd=get(hsp2,'XData'); yd=get(hsp2,'YData'); zd=get(hsp2,'ZData');
% The yellow Point should lie on the plane as we have assumed that the Plane crosses through the point.
% Mathematical Validation Only clc; disp('Mathematical Validation of SURFACE');disp(' ') disp('Equation of PLANE is 1.X +1.Y +1.Z -33=0') for i=1:2*radius+1; valid=[xd(i,i) yd(i,i) zd(i,i) xd(i,i)+yd(i,i)+zd(i,i)-33 ] if valid(4)~=0 disp('EQUATION OF PLANE NOT SATISFIED'); break; end end disp('ALL POINTS VALIDATING PLANE EQUATION');
  1 commentaire
John D'Errico
John D'Errico le 25 Mar 2015
Please learn to use the code formatting button. It says "{} CODE". Select your code, then click that button. It allows others to actually read your code instead of the headache that you have given us here.

Réponses (0)

Cette question est clôturée.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by