File: sd2sci.sci

package info (click to toggle)
scilab 2.4-1
  • links: PTS
  • area: non-free
  • in suites: potato, slink
  • size: 55,196 kB
  • ctags: 38,019
  • sloc: ansic: 231,970; fortran: 148,976; tcl: 7,099; makefile: 4,585; sh: 2,978; csh: 154; cpp: 101; asm: 39; sed: 5
file content (122 lines) | stat: -rw-r--r-- 3,635 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
function txt=sd2sci(sd,zoom,orig)
// Copyright INRIA
[lhs,rhs]=argn(0)
if sd(1)<>'sd' then error('first argument has incorrect data type'),end
if rhs<3 then orig=['0';'0'],end
if type(orig)==1 then zoom=string(orig),end
if rhs<2 then zoom=['1';'1'],end
if type(zoom)==1 then zoom=string(zoom),end
if size(zoom,'*')==1 then zoom(2)=zoom(1),end
rect=sd(2)
xmx=rect(3);ymx=rect(4)
dx=abs(rect(3)-rect(1));dx=10^(-log(dx/100)/log(10))
dy=abs(rect(4)-rect(2));dy=10^(-log(dy/100)/log(10))
dxy=maxi(dx,dy)
txt=[]
txt='xsetech([0 0 1 1],'+sci2exp(sd(2))+')'
for k=3:size(sd)
  o=sd(k)
  if type(o)==15 then
    select o(1)
    case 'rect' then
      [x1,x2,y1,y2]=o(2:5)
      x1=round(dx*x1)/dx
      x2=round(dx*x2)/dx
      y1=round(dy*y1)/dy
      y2=round(dy*y2)/dy
      xi=string(mini(x1,x2));
      w=string(abs(x1-x2));
      yi=string(max(y1,y2));
      h=string(abs(y1-y2));
      txt=[txt;'xrect('+strcat([zsx(xi),zsy(yi),zx(w),zy(h)],',')+');']
    case 'frect' then
      [x1,x2,y1,y2]=o(2:5)
      x1=round(dx*x1)/dx
      x2=round(dx*x2)/dx
      y1=round(dy*y1)/dy
      y2=round(dy*y2)/dy
      xi=string(mini(x1,x2));
      w=string(abs(x1-x2));
      yi=string(max(y1,y2));
      h=string(abs(y1-y2));
      txt=[txt;'xrects(['+strcat([zsx(xi),zsy(yi),zx(w),zy(h)],';')+'],1);']  
    case 'fleche' then
      x=round(dx*o(2))/dx;y=round(dy*o(3))/dy
      txt=[txt;'xarrows('+zsx(sci2exp(x))+','+zsy(sci2exp(y))+',-1,-1);']
    case 'ligne' then
      z=o(2)';
      x=zsx(strcat(sci2exp(round(dx*z(:,1))/dx)))
      y=zsy(strcat(sci2exp(round(dy*z(:,2))/dy)))
      txt=[txt;'xpoly('+x+','+y+',""lines"");']
    case 'cercle' then
      c=o(2);r=round(dxy*o(3))/dxy
      c1=round(dx*c(1))/dx
      c2=round(dy*c(2))/dy
      xx=zsx(string(c1-r))
      yy=zsy(string(c2+r))
      rx=zx(string(2*r))
      ry=zy(string(2*r))
      txt=[txt;'xarc('+strcat([xx,yy,rx,ry,'0','64*360'],',')+');']
    case 'fcercle' then
      c=o(2);r=round(dxy*o(3))/dxy
      c1=round(dx*c(1))/dx
      c2=round(dy*c(2))/dy
      xx=zsx(string(c1-r))
      yy=zsy(string(c2+r))
      rx=zx(string(2*r))
      ry=zy(string(2*r))
      txt=[txt;'xfarc('+strcat([xx,yy,rx,ry,'0','64*360'],',')+');']      
    case 'comm' then
      z=o(2)
      com=sci2exp(o(3))
      x=zsx(string(round(dx*z(1))/dx))
      y=zsy(string(round(dy*z(2))/dy))
      txt=[txt;'xstring('+strcat([x,y,com,'0,0'],',')+');']
    case 'patts' then
      txt=[txt;'xset(''pattern'','+string(o(2))+')']
    case 'thick' then
      txt=[txt;'xset(''thickness'','+string(o(2))+')']  
    case 'symbs' then
      txt=[txt;'xset(''mark'','+string(o(2))+','+string(o(3))+')']
    case 'dashs' then
      txt=[txt;'xset(''dashes'','+string(o(2))+')']
    case 'fligne' then
      z=o(2)';
      x=zsx(strcat(sci2exp(round(dx*z(:,1))/dx)))
      y=zsy(strcat(sci2exp(round(dy*z(:,2))/dy)))
      txt=[txt;
	  'xpoly('+x+','+y+',''lines'')';
	  'xfpoly('+x+','+y+',1)'];
    case 'points' then 
      z=o(2)';
      x=zsx(strcat(sci2exp(round(dx*z(:,1))/dx)))
      y=zsy(strcat(sci2exp(round(dy*z(:,2))/dy)))
      txt=[txt;
	  'xpoly('+x+','+y+',""marks"")'];
    case "clipon" then
      txt=[txt;'xclip(''clipgrf'')']
    case "clipoff" then
      txt=[txt;'xclip()']     
    else

    end
  end
end
function t=zx(t)
if zoom(1)<>'1' then t($)=mulf(t($),zoom(1)),end



function t=zy(t)
if zoom(2)<>'1' then t($)=mulf(t($),zoom(2)),end


function t=zsx(t)
if zoom(1)<>'1' then t($)=mulf(t($),zoom(1)),end
if orig(1)<>'0' then t(1)=addf(orig(1),t(1)),end

function t=zsy(t)
if zoom(2)<>'1' then t($)=mulf(t($),zoom(2)),end
if orig(2)<>'0' then t(1)=addf(orig(2),t(1)),end