Plotting a plane normal to a vector and passing through a point
Show older comments
I'm relatively new to MATLAB and am trying to work through a process for plot a plane normal to a specified vector and that passes through a specified point. Here is my approach substituting artificial values in for coordinates:
A=[... ... ...] dimensions of A are 512x512x11 and A represents a 3D matrix of values
% Read in XYZ coordinates for point #1
pt1=[1,2,1];
% Read in XYZ coordinates for point #2
pt2=[3,6,1];
% Plot a line connecting these two points
plot3([pt1(1);pt2(1)],[pt1(2);pt2(2)],[pt1(3);pt2(3)]);
% Choose a point #3 along the line where point of interest is
pt3=[2,4,1];
% Create a vector that originates from point #1 and extends to point #2
n=[(pt1(1)-pt2(1)) (pt1(2)-pt2(2)) (pt1(3)-pt2(3))];
% Create a plane orthogonal to vector at point #3
array=zeros(512,512,numFrames);
figure
for a=1:512
for b=1:512
for c=1:numFrames
if n(1)*(a-pt3(1))+n(2)*(b-pt3(2))+n(3)*(c-pt3(3))==0
array(a,b,c)=A(a,b,c);
plot3(a,b,c)
hold on
end
end
end
end
---------
this runs off the scalar equation of the plane through point P0(x0,y0,z0), called point #3 above, with normal vector n=<a,b,c>:
a*(x-x0)+b*(y-y0)+c*(z0-z)=0
Right now the output is a series of points in the z-direction at point #3; whereas I was expecting to generate a plane that satisfied the above equation. Any feedback or comments would be appreciated. Thank you,
Accepted Answer
More Answers (0)
Categories
Find more on 2-D and 3-D Plots 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!