Rotate 3D quiver
13 views (last 30 days)
Show older comments
I am trying to plot 3D vectors of the scene using quiver 3 function, The output upsidedown!
I reverse all the axis X,Y and Z ... I try to reverse each one separately
I could not get what I really want .. I want it as we see it in the reality
as you see in the image ... the wall and floor not adjust correctly!
How can I make them in the correct position?
I am including the function that I am used to getting this plot
%---------------------3D VECTOR FLOW -------------------------%
function Display_3D_flow(Z,U,V,W,sample,scale,title_stg,...
filename,ymin,ymax,zmin,zmax,xmin,xmax)
pic_x=size(Z,1);
pic_y=size(Z,2);
U=U*scale;
V=V*scale;
W=W*scale;
rx=pic_x:-sample:1;
%rx=1:sample:pic_x;
ry=1:sample:pic_y;
littleU=U(rx,ry);
littleV=V(rx,ry);
littleW=W(rx,ry);
NO_AUTOMATIC_SCALING=0;
[littleX,littleY] = meshgrid(ry,rx);
littleZ=Z(rx,ry);
figure
quiver3(littleX,littleY,littleZ,littleU,littleV,littleW,NO_AUTOMATIC_SCALING);
%view([90,90,-180])
axis([xmin xmax ymin ymax zmin zmax])
title(title_stg)
xlabel('X-axis')
ylabel('Y-axis')
zlabel('Z-axis')
hold on
%set(gca,'YDir','Reverse')
set(gca,'ZDir','Reverse')
%set(gca,'XDir','Reverse')
hold off
jpg_filename=[filename,'.jpg'];
print('-djpeg',jpg_filename)
end
5 Comments
Bjorn Gustavsson
on 10 Sep 2019
The only thing we others can say for sure is that your "wall" and "floor" labels are in unusual positions. If you change those two around then it would be fine for us. Otherwise you have done some mix-up with what coordinates you put in the x-y-z and vx-vy-vz variables. Your quiver3-call is "correct" for the x-y-z-vx-vy-vz variables you call it with. If you skip the set(gca,'ZDir','Reverse') call you will get z increasing upwards. After that you might have to figure out what your variables actually represent.
HTH
Accepted Answer
Seereen
on 10 Sep 2019
Edited: Seereen
on 10 Sep 2019
3 Comments
Bjorn Gustavsson
on 11 Sep 2019
Have a manual look at a couple of components of your [X,Y,Z] (your positions) and your motion components [U,V,W] - preferably some you have at least a hunch about what they should be. For example something like this:
[X(1,1),Y(1,1),Z(1,1)] % should give you the position of the first point
[U(1,1),V(1,1),W(1,1)] % The corresponding motion-vector.
Then you can repeat that for littleX, littleY, and littleZ etc. Just to trace where things go strange...
HTH
More Answers (2)
Bjorn Gustavsson
on 10 Sep 2019
Matlab uses right-handed coordinate systems (sensible), with the default convention that z is in the upward vertical direction in 3-D plots. My guess is that you've either goofed (very very unlikely, but "I know you as I know myself") with the wall-floor labling, or you've used a different notation for your x-y-z coordinates? The rest looks OK.
Bruno Luong
on 11 Sep 2019
Edited: Bruno Luong
on 11 Sep 2019
Another alternative: instead of reordering your data/plot parameters, you can change the view.
Play on camera parameters, especially important in your case is CameraUpVector
s=5*peaks;
ax = subplot(1,2,1);
surf(ax,s);
axis equal
ax = subplot(1,2,2);
surf(ax,s);
set(ax,'CameraUpVector',[0 -1 0]);
axis equal
Note: some interactive tool such as rotate3d won't work well with CameraUpVector different than default value of [0 0 1];
0 Comments
See Also
Categories
Find more on Vector Fields 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!