How to get slice planes correct?

I am trying to get a 3 planes rotated at different angles. I tried 0, 15 and 75 degrees. However, function rotate slices an additional information of the plot in such a way that if you increase a polar angle, the amount of cut-off image area increases. I cant seem to get around this problem. Does anyone know how to rotate a plane given a set of data. i.e. if i want plane to be rotated by required degrees, the plane actually contain these values and is rotated by required angle.
I will be immensely grateful for your help.
With kind regards, Sholpan

 Accepted Answer

Matt J
Matt J on 25 Apr 2013
If you're using IMROTATE, that shouldn't be a problem. You have the option to crop the rotated image to the original image dimensions, but no cropping is the default.

4 Comments

Sholpan
Sholpan on 25 Apr 2013
Edited: Matt J on 25 Apr 2013
I create a rotated plane first using:
new_z_1 = new_y*cos(deg2rad(0));
[xnew ynew znew_1] = meshgrid(new_x,new_y,new_z_1);
zmin_1 = min(znew_1(:));
zmax_1 = max(znew_1(:));
hslice_1 = surf(linspace(xmin,xmax,129),...
linspace(ymin,ymax,129),...
zeros(129));
rotate(hslice_1,[-1,0,0],30,[0,0,0])
I delete the slice then saving xd,yd,zd, and fill in the rotated plane with my data:
xd_1 = get(hslice_1,'XData');
yd_1 = get(hslice_1,'YData');
zd_1 = get(hslice_1,'ZData');
delete(hslice_1)
h = slice(xnew,ynew,znew_1,U_total,xd_1,yd_1,zd_1);
set(h,'FaceColor','interp',...
'EdgeColor','none',...
'DiffuseStrength',.8);
hold on;
But when i change the angle, it changes my resulting plane and i dont understand why. Z values are kept within the inital limits for some strange reason.
But everything is fine now? Since you accepted my Answer, I assume so.
it's still doesnt work but thank you for your help. I am constructing the images from the data and not the image files
Matt J
Matt J on 25 Apr 2013
Edited: Matt J on 25 Apr 2013
Z values are kept within the inital limits for some strange reason.
You have only specified U_total over the initial range znew_1. SLICE has no way of extrapolating U_total data outside the range of data you have given it.

Sign in to comment.

More Answers (1)

Matt J
Matt J on 25 Apr 2013
Edited: Matt J on 25 Apr 2013
If you're just trying to rotate a set of points in 3D, then this FEX file should be helpful
It is more direct than using SURF plots,
data=[linspace(xmin,xmax,129);...
linspace(ymin,ymax,129);...
zeros(1,129)];
rotdata = AxelRot(data,30,[-1 0 0 ],[0 0 0]);
xd_1 = rotdata(1,:);
yd_1 = rotdata(2,:);
zd_1 = rotdata(3,:);

Asked:

on 25 Apr 2013

Community Treasure Hunt

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

Start Hunting!