Rotate 3D quiver

조회 수: 12 (최근 30일)
Seereen
Seereen 2019년 9월 6일
댓글: Bjorn Gustavsson 2019년 9월 11일
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