How to define a plane by matrices instead of a function?

15 views (last 30 days)
I want to define the following plane which runs through 3 points, by matrices.
So I can use the slice function.
slice(X,Y,Z,V,xslice,yslice,zslice) draws slices for the volumetric data V. Specify X,Y, and Z as the coordinate data. Specify xslice, yslice, and zslice as the slice locations using one of these forms:
  • To draw one or more slice planes that are orthogonal to a particular axis, specify the slice arguments as a scalar or vector.
  • To draw a single slice along a surface, specify all the slice arguments as matrices that define a surface.
I don't know how to define a surface as a matrices.
If you runs this code you will get the function for the plane. Yf.
How to descripe a plane by matrices instead of a function?
A = [104,122,111];
B = [253,122,153];
C = [104,124,111];
normal = cross(A-B, A-C)
syms X Y Z
P = [X,Y,Z];
realdot = @(u, v) u*transpose(v);
plane_function=realdot(P-A,normal);
yf=solve(plane_function,Y)
Yf = matlabFunction(yf) %the PLANE
S = syms;
cellfun(@clear, S);

Accepted Answer

Matt J
Matt J on 22 Jan 2020
Edited: Matt J on 22 Jan 2020
For example,
A = [104,122,111];
B = [253,122,153];
C = [104,124,111];
normal=normalize( cross(A-B,A-C),'norm'); %calculate plane parameters
P=dot(A,normal);
load mri %set up some volume data
[X,Y,Z]=meshgrid(1:128,1:128,(1:27)-110);
V = single(squeeze(D));
[x,y]=meshgrid(linspace(1,128,512)); %compute sample locations in plane
z=(normal(1)*x+normal(2)*y-P)./normal(3);
h=slice(X,Y,Z,V,x,y,z,'cubic'); %plot
colormap(gray(256))
h.LineStyle='none';
  2 Comments
Matt J
Matt J on 22 Jan 2020
OP's comment moved here:
Thank you, that is exactly what I mean!
However, my 3D image is a .tif image. Which gives the following error:
V = single(squeeze(I));
Error using single
Conversion to single from Tiff is not possible.
Is there another way to use the code?
Matt J
Matt J on 22 Jan 2020
You must read in all the .tif slices (as grayscale) and organize them as an MxNxP 3D array.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!