Setting camera properties on axes is not working as I'm expecting
古いコメントを表示
Hi,
I'm trying to display a model consisting of many planes. I'm using 'surf' to draw these planes. Similar to this:
for k = 1:100
X_k = X(K); % Similar for other vars
hold on; surf(X_k,Y_k,Z_k,C_k,'FaceColor','texturemap','EdgeColor','none');
hold off;
end
After the loop I try to set the axes camera properties, simlar to this:
set(gca,'CameraPosition', center(1:3), 'CameraPositionMode', 'manual', ...
'CameraTarget', target(1:3), 'CameraTargetMode', 'manual', ...
'CameraUpVector', up(1:3), 'CameraUpVectorMode', 'manual', ...
'CameraViewAngle', viewangle, 'CameraViewAngleMode', 'manual');
drawnow;
If I get the parameters from the axes again, by using get(gca, ... I don't get the same value as I just have set.
Why is that? Is something being automatically calculated for me? What I notice is, that camera position and target has changed.
採用された回答
その他の回答 (1 件)
Daniel Shub
2011 年 11 月 9 日
This seems to work for me
[x, y, z] = peaks;
mesh(x, y, z)
hold on
set(gca,'CameraPosition', center(1:3), 'CameraPositionMode', 'manual', ...
'CameraTarget', target(1:3), 'CameraTargetMode', 'manual', ...
'CameraUpVector', up(1:3), 'CameraUpVectorMode', 'manual', ...
'CameraViewAngle', viewangle, 'CameraViewAngleMode', 'manual');
all([isequal(get(gca,'CameraPosition'), center)
isequal(get(gca,'CameraTarget'), target)
isequal(get(gca,'CameraUpVector'), up)
isequal(get(gca,'CameraViewAngle'), viewangle)])
for ii = 1:10
mesh(x, y, z+10*ii);
all([isequal(get(gca,'CameraPosition'), center)
isequal(get(gca,'CameraTarget'), target)
isequal(get(gca,'CameraUpVector'), up)
isequal(get(gca,'CameraViewAngle'), viewangle)])
end
What are you expecting to get and what are you getting?
2 件のコメント
Axel
2011 年 11 月 9 日
Daniel Shub
2011 年 11 月 9 日
See my edited code which now plots new surfaces/meshes in a loop. The camera angle seems to stay constant.
カテゴリ
ヘルプ センター および File Exchange で Lighting, Transparency, and Shading についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!