ptrc_one_sample_vis-3d.sce 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. fileName="one_case_data-3d.txt";
  2. generateNewCase=1;
  3. graphSize=[800,800]; fontSize=4; meshSize=48;
  4. exec("sample_data_parser.sce");
  5. xlfont(strcat(["../../documentation/fonts/cm-unicode-0.7.0/",..
  6. "CMU_Typewriter_Text-Medium.otf"]),0);
  7. rangeX=[min(dat.C(1,1:(dat.n))-dat.R'),max(dat.C(1,1:(dat.n))+dat.R')];
  8. rangeY=[min(dat.C(2,1:(dat.n))-dat.R'),max(dat.C(2,1:(dat.n))+dat.R')];
  9. rangeZ=[min(dat.C(3,1:(dat.n))-dat.R'),max(dat.C(3,1:(dat.n))+dat.R')];
  10. itemColorMap=[0, 0, 0; 2/3,0, 0; 0,2/3,0; 0,0,2/3;..
  11. 0,2/3,2/3; 2/3,0,2/3;2/3,2/3,0;..
  12. 11/51,0,11/51;1,1,1];
  13. function canvas(n)
  14. grw=graphWindows(n); clf(grw);
  15. grw.color_map=itemColorMap;
  16. grw.children.isoview="on";
  17. endfunction
  18. function centres()
  19. obj=scatter3d(dat.C(1,1:dat.n),dat.C(2,1:dat.n),dat.C(3,1:dat.n),..
  20. 64,itemColorMap(2:(dat.n+1),1:3),"fill",".");
  21. endfunction
  22. function [x,y,z]=tchSph(t,p)
  23. x=sin(t).*cos(p)*currR+currC(1)*ones(p);
  24. y=sin(t).*sin(p)*currR+currC(2)*ones(p);
  25. z=cos(t).*currR+currC(3)*ones(p);
  26. endfunction
  27. function circles()
  28. for i=1:1:dat.n
  29. currC=dat.C(1:dat.d,i); currR=dat.R(i);
  30. t=linspace(-%pi,%pi,meshSize); p=linspace(-%pi,%pi,meshSize);
  31. [xf,yf,zf]=eval3dp(tchSph,t,p);
  32. obj=plot3d(xf,yf,zf,..
  33. ebox=[rangeX(1),rangeX(2),rangeY(1),rangeY(2),..
  34. rangeZ(1),rangeZ(2)],flag=[0,3,4]);
  35. obj.foreground=i+1;
  36. end
  37. endfunction
  38. function startPoint(n)
  39. obj=scatter3d([rts(n).s(1).P(1),rts(n).s(1).P(1)],..
  40. [rts(n).s(1).P(2),rts(n).s(1).P(2)],..
  41. [rts(n).s(1).P(3),rts(n).s(1).P(3)],..
  42. 48,[itemColorMap(1,1:3);itemColorMap(1,1:3)],"fill","x");
  43. obj.thickness=2;
  44. obj=scatter3d([rts(n).s(1).P(1),rts(n).s(1).P(1)],..
  45. [rts(n).s(1).P(2),rts(n).s(1).P(2)],..
  46. [rts(n).s(1).P(3),rts(n).s(1).P(3)],..
  47. 128,[itemColorMap(1,1:3);itemColorMap(1,1:3)],"o");
  48. obj.thickness=2;
  49. endfunction
  50. function route(n,lastStep)
  51. for j=1:1:lastStep
  52. sXs(j)=rts(n).s(j).P(1);sYs(j)=rts(n).s(j).P(2);sZs(j)=rts(n).s(j).P(3);
  53. end
  54. param3d(sXs,sYs,sZs); obj=get("hdl"); obj.thickness=2; obj.foreground=1;
  55. endfunction
  56. function endPoint(n)
  57. obj=scatter3d(..
  58. [rts(n).s(length(rts(n).s)).P(1),rts(n).s(length(rts(n).s)).P(1)],..
  59. [rts(n).s(length(rts(n).s)).P(2),rts(n).s(length(rts(n).s)).P(2)],..
  60. [rts(n).s(length(rts(n).s)).P(3),rts(n).s(length(rts(n).s)).P(3)],..
  61. 512,[itemColorMap(1,1:3);itemColorMap(1,1:3)],"o"); obj.thickness=2;
  62. endfunction
  63. function bestGuessPoint()
  64. obj=scatter3d([bestGuess.P(1),bestGuess.P(1)],..
  65. [bestGuess.P(2),bestGuess.P(2)],..
  66. [bestGuess.P(3),bestGuess.P(3)],256,..
  67. [itemColorMap(8,1:3);itemColorMap(8,1:3)],"+");
  68. obj.thickness=2;
  69. endfunction
  70. function realPointPoint()
  71. obj=scatter3d([dat.realPoint(1),dat.realPoint(1)],..
  72. [dat.realPoint(2),dat.realPoint(2)],..
  73. [dat.realPoint(3),dat.realPoint(3)],256,..
  74. [itemColorMap(8,1:3);itemColorMap(8,1:3)],"*");
  75. obj.thickness=2;
  76. endfunction
  77. if exists("graphWindows")==0
  78. for i=1:1:dat.runs
  79. graphWindows(i)=scf(); gw=graphWindows(i);
  80. gw.figure_size=graphSize; gw.color_map=itemColorMap;
  81. end
  82. else
  83. if length(graphWindows)<>dat.runs
  84. clear graphWindows;
  85. for i=1:1:dat.runs
  86. graphWindows(i)=scf(); gw=graphWindows(i);
  87. gw.figure_size=graphSize; gw.color_map=itemColorMap;
  88. end
  89. end
  90. end
  91. for i=1:1:length(rts)
  92. canvas(i); centres(); circles(); startPoint(i);
  93. route(i,length(rts(i).s)); endPoint(i); bestGuessPoint(); realPointPoint();
  94. ax0=graphWindows(i).children; ax0.filled="off";
  95. ax0.font_style=0; ax0.font_size=fontSize-2;
  96. ax0.title.font_style=0; ax0.title.font_size=fontSize;
  97. ax0.x_label.font_style=0; ax0.x_label.font_size=fontSize;
  98. ax0.y_label.font_style=0; ax0.y_label.font_size=fontSize;
  99. ax0.z_label.font_style=0; ax0.z_label.font_size=fontSize;
  100. ax0.isoview="on";
  101. ax0.cube_scaling="off";
  102. xtitle([
  103. strcat(["Maximum of sensors uncertainty: ",string(dat.unc),";"]),
  104. strcat(["Number of known spheres: ",string(dat.n),";"]),
  105. strcat(["Start point #",string(i),..
  106. "; Final error: ",string(dat.error)])]);
  107. xs2png(graphWindows(i),strcat(["sample_start_point_",string(i),".png"]));
  108. //xs2svg(graphWindows(i),strcat(["sample_start_point_",string(i),".svg"]));
  109. end