Extracting Plane Orthogonal to a Line in 3D space

9 views (last 30 days)
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; AND z-coordinates=VALUES OBTAINED through the EQUATION of PLANE.Now How to MAP these coordinate values to extract data around the given Point. My Code is given .
clc;clear all;
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=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;
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) %Initial Plane
xdO=get(hsp,'XData');
ydO=get(hsp,'YData');
zdO=get(hsp,'ZData');
% Solving Equation of PLANE for obtaining Orthogonal plane
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);
pause(2)
delete(hsp)
hsp2=surf(x,y,z_value); % This is Orthogonal Plane to LINE
xd=get(hsp2,'XData'); % Coordinates of Plane
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.
  3 Comments
John D'Errico
John D'Errico on 25 Mar 2015
Edited: John D'Errico on 25 Mar 2015
Argh. Is this how you write code? MATLAB does not charge for white space, or per line of code. You have pasted in one strung out stream of consciousness piece of code. I've done my best to untangle the mess now.
Muhammad Jawaid
Muhammad Jawaid on 25 Mar 2015
Dear John, I have Edited Code and removed some unnecessar line. Just give a try now. You will see that already have Obtained plane that is Orthogonal to LINE and passes through the point P1[5,18,10]. Next step is my question, that HOW to extract Intensity values from a 3D Volume corresponding to this PLANE?
(Remember that X,Y coordinates are [-64:64] and Z coordinate values are Obtained after evaluation PLANE equation. You can check out xd,yd,zd)
Thank You Very Much.
Hopefully I have explained my question, still you can ask me for further explanation.

Sign in to comment.

Answers (1)

John D'Errico
John D'Errico on 25 Mar 2015
It is not at all clear what you are trying to do in that long piece of code, even after I completely untangled the code.
Computing a plane orthogonal to a line is a trivial thing to do however, but all depends on what you intend to do with it. A plane is spanned by two vectors, orthogonal to the line. We can get such a pair of vectors using null.
P1 = rand(1,3)
P1 =
0.91338 0.63236 0.09754
P2 = rand(1,3)
P2 =
0.2785 0.54688 0.95751
V = null(P1 - P2)
V =
-0.079711 0.80195
0.99601 0.040152
0.040152 0.59604
So the columns of V are vectors orthogonal to that line.
We can write any point that lies in the plane as some linear combination of those two vectors, plus some specific point in the plane. So if X0 is a point in the plane, then the equation of the plane is
dot(X - X0,P1 - P2) = 0
What you actually want to do in that mess of code, that I have no idea.

Categories

Find more on Triangulation Representation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!