GNU Octave,如何在交互式窗口中旋转时停止调整3D轴的大小?

时间:2018-03-31 21:04:55

标签: octave

问题:有没有办法阻止八度音阶试图将轴对象自动调整到一个恒定大小的框中,而是让观察比例保持不变?

我喜欢向学生展示大量与各种数学/科学主题相关的3D图,并使用默认的交互式窗口(Octave 4.0到Debian amd64存储库)在课堂上实时旋转图形。问题是所产生的大小调整会分散对象/动画轨迹的形状。

这是我正在使用的简单散点图动画,但这适用于所有3d绘图。

#!/usr/bin/octave-cli

clear all;
close all;


planetx=[-0.1478672,  -0.7257694,  -0.1756896,   1.3832219;
 -0.0381809,  -0.7160833,  -0.2610456,   1.3850799;
  0.0737428, -0.6924100,  -0.3444268 ,  1.3831345;
  0.1793219,  -0.6552495,  -0.4251856 ,  1.3774159;
  0.2688712,  -0.6053663,  -0.5026964,   1.3679664;
  0.3311067,  -0.5437714,  -0.5763614,  1.3548404;
  0.3531110,  -0.4716991,  -0.6456154 , 1.3381034;
  0.3219212,  -0.3905812,  -0.7099307,  1.3178316;
  0.2300102,  -0.3020162,  -0.7688217,  1.2941111;
  0.0855329,  -0.2077379,  -0.8218485,  1.2670372;
 -0.0814988,  -0.1095802,  -0.8686203,  1.2367138;
 -0.2318261,  -0.0094427,  -0.9087983,  1.2032523;
 -0.3384457,   0.0907458,  -0.9420979,  1.1667714;
 -0.3929915,   0.1890627,  -0.9682904,  1.1273956;
 -0.3988960,   0.2836267,  -0.9872039,  1.0852552;
 -0.3641642,   0.3726316,  -0.9987242,  1.0404850;
 -0.2977153,   0.4543788,  -1.0027945,  0.9932238;
 -0.2081496,   0.5273076,  -0.9994152,  0.9436139;
 -0.1036023,   0.5900227,  -0.9886429,  0.8917999;
  0.0079838,   0.6413199,  -0.9705888,  0.8379287];

planety=[-0.4466930,  -0.0252958,   0.9659716,  -0.0238017;
 -0.4657149,  -0.1263067,   0.9471212,   0.0520870;
 -0.4508105,  -0.2248822,   0.9208844,   0.1278263;
 -0.4013623,  -0.3190893,   0.8874673,   0.2032115;
 -0.3181219 , -0.4070912,   0.8471345,   0.2780418;
 -0.2041932 , -0.4871833,   0.8002063,   0.3521215;
 -0.0669533,  -0.5578254,   0.7470558,   0.4252601;
  0.0789006,  -0.6176696,   0.6881051,   0.4972739;
  0.2085279,  -0.6655848,   0.6238214,   0.5679859;
  0.2899490,  -0.7006754,   0.5547124,   0.6372265;
  0.2993354,  -0.7222964,   0.4813220,   0.7048344;
  0.2378102,  -0.7300623,   0.4042244,   0.7706562;
  0.1278686,  -0.7238523,   0.3240197,   0.8345477;
 -0.0036336,  -0.7038105,   0.2413281,   0.8963733;
 -0.1357070,  -0.6703412,   0.1567847,   0.9560064;
 -0.2544710,  -0.6241000,   0.0710340,   1.0133298;
 -0.3512399,  -0.5659813,  -0.0152755,   1.0682353;
 -0.4205857,  -0.4971011,  -0.1014962,   1.1206241;
 -0.4590497,  -0.4187770,  -0.1869867,   1.1704064;
 -0.4644300,  -0.3325042,  -0.2711164,   1.2175012];

planetz=[ -2.3139e-02,   4.1378e-02,   2.0503e-04,  -3.4412e-02;
 -3.4756e-02,   3.9440e-02,   2.0468e-04,  -3.2867e-02;
 -4.3806e-02,   3.6728e-02,   2.0433e-04,  -3.1231e-02;
 -4.9452e-02,   3.3297e-02,   2.0398e-04,  -2.9511e-02;
 -5.0867e-02,   2.9217e-02,   2.0363e-04,  -2.7710e-02;
 -4.7267e-02,   2.4568e-02,   2.0328e-04,  -2.5834e-02;
 -3.8071e-02,   1.9444e-02,   2.0292e-04,  -2.3890e-02;
 -2.3288e-02,   1.3946e-02,   2.0256e-04,  -2.1882e-02;
 -4.2578e-03,   8.1806e-03,   2.0220e-04,  -1.9816e-02;
  1.5659e-02,   2.2609e-03,   2.0183e-04,  -1.7700e-02;
  3.1762e-02,  -3.6987e-03,   2.0145e-04,  -1.5537e-02;
  4.0539e-02,  -9.5832e-03,   2.0107e-04,  -1.3335e-02;
  4.1349e-02,  -1.5280e-02,   2.0067e-04,  -1.1099e-02;
  3.5618e-02,  -2.0679e-02,   2.0027e-04,  -8.8346e-03;
  2.5376e-02,  -2.5678e-02,   1.9986e-04,  -6.5487e-03;
  1.2491e-02,  -3.0182e-02,   1.9944e-04,  -4.2464e-03;
 -1.5080e-03,  -3.4104e-02,   1.9901e-04,  -1.9337e-03;
 -1.5389e-02,  -3.7371e-02,   1.9856e-04,   3.8413e-04;
 -2.8122e-02, -3.9918e-02,   1.9810e-04,   2.7015e-03;
 -3.8798e-02,  -4.1699e-02,   1.9762e-04,   5.0131e-03;];

N=size(planetx)
N=N(1,1)

figure('position',[50,50,1000,750]);
h=scatter3(planetx(1,:),planety(1,:),planetz(1,:) , 10*[3,4,5,4], 
[3,4,5,4],'filled');

axis([-2,2,-2,2,-1,1],'square');
set(gca,'fontsize',20)
axis('manual')
#box('off')
#axis('off')
view([15,15]);
hold on;

p1=plot3(planetx(1:20,1),planety(1:20,1),planetz(1:20,1),':')
p2=plot3(planetx(1:20,2),planety(1:20,2),planetz(1:20,2),':')
p3=plot3(planetx(1:20,3),planety(1:20,3),planetz(1:20,3),':')
p4=plot3(planetx(1:20,4),planety(1:20,4),planetz(1:20,4),':')

ans=input('loaded, hit enter to start!')

for i=1:N
    #[AZ,EL]=view();
    set(h, 'xdata', planetx(i,:) , 'ydata', planety(i,:), 'zdata', 
    planetz(i,:))
    title(sprintf('YEAR=%f',2000+i*200/14010 ))

    set(p1,'xdata',planetx(1:i,1),'ydata',planety(1:i,1),'zdata', planetz(1:i,1))
    set(p2, 'xdata', planetx(1:i,2),'ydata',planety(1:i,2),'zdata',planetz(1:i,2))
    set(p3, 'xdata', planetx(1:i,3),'ydata',planety(1:i,3),'zdata',planetz(1:i,3))
    set(p4, 'xdata', planetx(1:i,4),'ydata',planety(1:i,4),'zdata',planetz(1:i,4))
    pause(1)
endfor;
ans=input('hit to close!')

1 个答案:

答案 0 :(得分:1)

这似乎可能是旧版八度版的错误。 在我的系统(octave 4.2.1 - linux)上,它似乎可以正常工作。

<子> PS。忽略这些故障,它们是与我使用的屏幕录像机相关的错误

更新:为了回应Cris的评论,可能是罗伯特所指的是相机似乎是如何“缩小”以便容纳完整的“盒子”时一个人旋转。

您可以通过将cameraviewanglemode属性从“auto”更改为“manual”来更改此行为。这样可以在没有相机从其位置移动的情况下获得更平滑的旋转体验。

>> set(gca, 'cameraviewanglemode', 'manual')

视觉比较:

'自动模式'与'手动模式'

其他“相机”相关属性也可能有用。输入get(gca, 'camera')以获取相关属性的列表。 (或者只是查看手册中的this page默认值等)。