ptrc_one_sample_vis-2d.sce 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. fileName="one_case_data-2d.txt";
  2. generateNewCase=1;
  3. graphSize=[800,800]; fontSize=4;
  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. function c=rainbowColorMap(n)
  10. inc=-5/(n-1);
  11. cc=[1,0,1]; pp=1; cc(pp)=cc(pp)-inc;
  12. m=[1,0,1;1,0,0];
  13. for i=1:1:n
  14. cc(pp)=cc(pp)+inc;
  15. if(inc>0 & cc(pp)>1)
  16. diff=-(cc(pp)-1); cc(pp)=1; pp=modulo(pp,3)+1;
  17. cc(pp)=cc(pp)+diff; inc=-inc;
  18. end
  19. if(inc<0 & cc(pp)<0)
  20. diff=-cc(pp); cc(pp)=0; pp=modulo(pp,3)+1;
  21. cc(pp)=cc(pp)+diff; inc=-inc;
  22. end
  23. for s=1:1:3 m(i,s)=cc(s); end
  24. end
  25. m(n,1)=1; m(n,2)=0; m(n,3)=0; c=m;
  26. endfunction
  27. itemColorMap=list('#aa0000','#00aa00','#0000aa','#00aaaa','#aa00aa',..
  28. '#aaaa00','#664422','#aa5500','#aa5555','#550055',..
  29. '#ffd9d9','#e1ffe1','#def0ff','#e6ffff','#ffe6ff',..
  30. '#ffffd9','#f0e8e1','#ffe6cc','#ffecec');
  31. function z=lambdaFunc(x,y)
  32. pPnt=[x;y];
  33. sumOfDst=0;
  34. for i=1:1:dat.n
  35. sumOfDst=sumOfDst+abs(sqrt(sum((pPnt-dat.C(1:dat.d,i))^2))-dat.R(i));
  36. end
  37. z=-sumOfDst;
  38. endfunction
  39. function canvas(n)
  40. grw=graphWindows(n); clf(grw);
  41. grw.color_map=rainbowColorMap(1024);
  42. /* heatmap */
  43. Sfgrayplot(linspace(rangeX(1),rangeX(2),32),..
  44. linspace(rangeY(1),rangeY(2),32),lambdaFunc,colminmax=[1;1024]);
  45. colorbar(,,colminmax=[1;1024]); ax0=gca(); ax0.isoview='on';
  46. endfunction
  47. function centres()
  48. for i=1:1:dat.n
  49. obj=plot(dat.C(1,i),dat.C(2,i),'Color',itemColorMap(i));
  50. obj.mark_style=0; obj.mark_size=5; obj.line_mode="off";
  51. end
  52. endfunction
  53. function circles()
  54. for i=1:1:dat.n
  55. a=-%pi:0.01:%pi;
  56. x=dat.C(1,i)+dat.R(i)*sin(a); y=dat.C(2,i)+dat.R(i)*cos(a);
  57. obj=plot(x,y,'Color',itemColorMap(i)); obj.thickness=2;
  58. end
  59. endfunction
  60. function startPoint(n)
  61. obj=plot(rts(n).s(1).P(1),rts(n).s(1).P(2),'Color','#000000');
  62. obj.mark_style=9; obj.mark_size=10; obj.mark_background=0;
  63. obj=plot(rts(n).s(1).P(1),rts(n).s(1).P(2),'Color','#000000');
  64. obj.mark_style=2; obj.mark_size=6; obj.mark_background=0;
  65. endfunction
  66. function route(n,lastStep)
  67. for j=1:1:lastStep
  68. sXs(j)=rts(n).s(j).P(1); sYs(j)=rts(n).s(j).P(2);
  69. end
  70. plot(sXs,sYs,'Color','#000000'); obj=get("hdl");
  71. obj.children.mark_size=0; obj.children.thickness=1;
  72. obj.children.line_mode="on";
  73. endfunction
  74. function endPoint(n)
  75. obj=plot(rts(n).s(length(rts(n).s)).P(1),rts(n).s(length(rts(n).s)).P(2),..
  76. 'Color','#000000');
  77. obj.mark_style=9; obj.mark_size=24; obj.mark_background=0;
  78. endfunction
  79. function bestGuessPoint()
  80. obj=plot(bestGuess.P(1),bestGuess.P(2),'Color','#550055');
  81. obj.mark_style=1; obj.mark_size=16; obj.mark_background=0; obj.thickness=2;
  82. endfunction
  83. function realPointPoint()
  84. obj=plot(dat.realPoint(1),dat.realPoint(2),'Color','#550055');
  85. obj.mark_style=10; obj.mark_size=16; obj.mark_background=0; obj.thickness=2;
  86. endfunction
  87. if exists("graphWindows")==0
  88. for i=1:1:dat.n
  89. graphWindows(i)=scf();
  90. graphWindows(i).figure_size=graphSize;
  91. graphWindows(i).color_map=rainbowColorMap(1024);
  92. end
  93. else
  94. if length(graphWindows)<>dat.n
  95. clear graphWindows;
  96. for i=1:1:dat.n
  97. graphWindows(i)=scf();
  98. graphWindows(i).figure_size=graphSize;
  99. graphWindows(i).color_map=rainbowColorMap(1024);
  100. end
  101. end
  102. end
  103. for i=1:1:length(rts)
  104. canvas(i); centres(); circles(); startPoint(i);
  105. route(i,length(rts(i).s)); endPoint(i); bestGuessPoint(); realPointPoint();
  106. gw=gcf(); ax0=gw.children(1); ax0.filled="off";
  107. ax1=gw.children(2); ax1.filled="off";
  108. ax0.font_style=0;ax1.font_style=0;ax1.title.font_style=0;
  109. ax1.x_label.font_style=0;ax1.y_label.font_style=0;
  110. ax0.font_size=fontSize;ax1.font_size=fontSize;ax1.title.font_size=fontSize;
  111. ax1.x_label.font_size=fontSize;ax1.y_label.font_size=fontSize;
  112. xtitle([
  113. strcat(["Maximum of sensors uncertainty: ",string(dat.unc),";"]),
  114. strcat(["Number of known spheres: ",string(dat.n),";"]),
  115. strcat(["Start point #",string(i),..
  116. "; Final error: ",string(dat.error)])]);
  117. xs2png(graphWindows(i),strcat(["sample_start_point_",string(i),".png"]));
  118. //xs2svg(graphWindows(i),strcat(["sample_start_point_",string(i),".svg"]));
  119. //xs2eps(graphWindows(i),strcat(["sample_start_point_",string(i),".eps"]));
  120. end