MATLAB Answers

Extracting Plane Orthogonal to a Line in 3D space

51 views (last 30 days)
Muhammad Jawaid
Muhammad Jawaid on 25 Mar 2015
Edited: Muhammad Jawaid on 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; 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
% 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
hold on
pt=[5 18 10];
rotate(hsp,[0 0 1],0) %Initial Plane
% 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
% Generate XY Range for Assignment
hsp2=surf(x,y,z_value); % This is Orthogonal Plane to LINE
xd=get(hsp2,'XData'); % Coordinates of Plane
% The yellow Point should lie on the plane as we have assumed that the Plane crosses through the point.


John D'Errico
John D'Errico on 25 Mar 2015
So why not just fix the FIRST one, rather than reposting a second question? Worse, you did not do as I said. You clicked on the code button, THEN pasted in your code.
John D'Errico
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.


Sign in to comment.

Community Treasure Hunt

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

Start Hunting!