フィルターのクリア

Easy way to set camera viewing axis normal to a plane

181 ビュー (過去 30 日間)
Jason
Jason 2011 年 7 月 2 日
コメント済み: Timothy Russell 2021 年 9 月 29 日
Is there an easy way to set the camera viewing axis normal to one of the planes in a 3D plot. That is set the camera to only look at the xy plane or xz plane, etc. Trying to position the camera manually does not work well and is very frustrating.
I created a bunch of .fig files of some data points in 3D space and now I am trying to visualize them from different angles, namely looking down(xy plane) and across(xz-yz planes).
Thanks for the help.

回答 (3 件)

Matt Fig
Matt Fig 2011 年 7 月 2 日
Run this to see. Look at the view of the plot that pops up, then press return to see the next view. Do this twice.
plot3(0,0,0)
axis([-1 1 -1 1 -1 1])
xlabel('X')
ylabel('Y')
zlabel('Z')
view(0,90) % XY
pause
view(0,0) % XZ
pause
view(90,0) % YZ
  2 件のコメント
Jason
Jason 2011 年 7 月 8 日
Thanks for the quick response and help.
Timothy Russell
Timothy Russell 2021 年 9 月 29 日
how do you rotate the YZ view 90 degrees?

サインインしてコメントする。


Paulo Silva
Paulo Silva 2011 年 7 月 2 日

Massimo Ciacci
Massimo Ciacci 2016 年 5 月 2 日
編集済み: Massimo Ciacci 2016 年 5 月 2 日
I guess the following function should do, it is based on the fact that the conversion [x,y,z] to [az,el] to [x,y,z] is
x=sin(az)*cos(el)
y=cos(az)*cos(el)
z=sin(el)
and therefore
az = 180/pi*asin(x/sqrt(x^2+y^2));
el = 180/pi*asin(z);
---------------
function [az,el]=normalToAzimuthElevationDEG(x,y,z, applyView)
if nargin < 3
applyView = 0;
end
if length(x)>1
v = x;
if nargin > 1
applyView = y;
end
x=v(1);
y=v(2);
z=v(3);
end
if x==0 && y==0
x =eps;
end
vNorm = sqrt(x^2+y^2+z^2);
x=x/vNorm;
y=y/vNorm;
z=z/vNorm;
az = 180/pi*asin(x/sqrt(x^2+y^2));
el = 180/pi*asin(z);
if applyView
thereIsAnOpenFig = ~isempty(findall(0,'Type','Figure'));
if thereIsAnOpenFig
axis equal
view([az,el]);
%the normal to the plane should now appear as a point
plot3([0,x],[0,y],[0,z],'linewidth',3)
end
end

カテゴリ

Help Center および File ExchangeCamera Views についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by