Rotate 3D quiver

29 views (last 30 days)
Seereen
Seereen on 6 Sep 2019
Commented: Bjorn Gustavsson on 11 Sep 2019
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
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
Seereen
Seereen on 10 Sep 2019
The lable just to explaine my issue ... I wnat to rotate the scene to have the wall and floor in the right position

Sign in to comment.

Accepted Answer

Seereen
Seereen on 10 Sep 2019
Edited: Seereen on 10 Sep 2019
For any one face this in the future, I change the order of the variable in the quiver to become like this
instead of using X Y Z order now I am using X Z Y
quiver3(littleX,littleZ,littleY,littleU,littleW,littleV,NO_AUTOMATIC_SCALING);
axis([xmin xmax zmin zmax ymin ymax])
This change the scene to looks better
  3 Comments
Seereen
Seereen on 11 Sep 2019
Also this is confusing me ... naming the values is important to me ! .. U, V, W in my code represent the motion of the scene in 3D. U the motion in X direction , V the motion in the Y direction and W is the motion in the Z direction ! ..
Ploting them as it is give me rotated scene ... when I change the order I got the right direction !
Do you know why it is in worng direction like this?
Bjorn Gustavsson
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

Sign in to comment.

More Answers (2)

Bjorn Gustavsson
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.
  1 Comment
Seereen
Seereen on 10 Sep 2019
Actually this labling ( wall and floor) not from quiver ... I just added by preview app to explain my issue
I want to change the direction of the 3D scene

Sign in to comment.


Bruno Luong
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];

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!