Rotate 3D quiver

15 次查看(过去 30 天)
Seereen
Seereen 2019-9-6
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 个评论
Bjorn Gustavsson
Bjorn Gustavsson 2019-9-10
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 2019-9-10
The lable just to explaine my issue ... I wnat to rotate the scene to have the wall and floor in the right position

请先登录,再进行评论。

采纳的回答

Seereen
Seereen 2019-9-10
编辑:Seereen 2019-9-10
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 个评论
Seereen
Seereen 2019-9-11
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 2019-9-11
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

请先登录,再进行评论。

更多回答(2 个)

Bjorn Gustavsson
Bjorn Gustavsson 2019-9-10
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 个评论
Seereen
Seereen 2019-9-10
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

请先登录,再进行评论。


Bruno Luong
Bruno Luong 2019-9-11
编辑:Bruno Luong 2019-9-11
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];

类别

Help CenterFile Exchange 中查找有关 Vector Fields 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by