[doc] add the gnuplot files.
[hkl.git] / Documentation / figures / diffractometer.asy
blobc745256741bff1c0271048165c3dfe53909dd33c
1 import three;
2 import solids;
4 restricted surface unitsolidcylinder = surface(unitcylinder,
5                                                unitdisk,
6                                                shift(Z)*unitdisk);
8 surface torus(real R, real a, real theta1, real theta2)
10   //return surface(revolution(reverse(Circle(R*X,a,Y,32)),Z,90,345));
12   triple f(pair t) {
13     return ((R+a*cos(t.y))*cos(t.x),(R+a*cos(t.y))*sin(t.x),a*sin(t.y));
14   }
16   surface s = surface(f, (radians(theta1),0), (radians(theta2),2pi), 8, 8, Spline);
18   return s;
21 surface carrow(real radius, real a,
22                real theta1, real theta2, int direction)
24   surface s;
25   
26   s.append(torus(radius, a, theta1, theta2));
28   if (direction < 0)
29     s.append( rotate(theta1, Z) * shift(radius, 0, 0) * rotate(90., X) * scale(2*a, 2*a, 6*a) * unitsolidcone );
30   else
31     s.append( rotate(theta2, Z) * shift(radius, 0, 0) * rotate(-90., X) * scale(2*a, 2*a, 6*a) * unitsolidcone );
33   return s;
36 surface tpp(real height, real radius)
38   // put the centre of the top surface of the cube at the origin
39   surface s=shift(-0.5, -0.5, -1) * unitcube;
40   s = shift(0, 0, -height) * scale(3*radius, 3*radius, radius/5) * s;
41   return s;
44 surface _support(real hight, real radius, int arrow1, int arrow2, bool draw_cylinder=false)
46   surface s;
47   real alpha = 0.1;
48   real dx = alpha * radius;
49   real dz = radius * sqrt(alpha * (2-alpha));
51   // becarefulle reference of the unitsolidcylinder and the unitcube are not
52   // at the same place, so me must take this into account.
53   if(draw_cylinder)
54     s.append( shift(0, 0, -hight) * scale(radius, radius, radius/5) * unitsolidcylinder );
55   s.append( shift(-dz, -radius+dx, -hight) * scale(2*dz, dx, hight) * unitcube );
56   s.append( shift(0, -radius+2*dx, 0) * rotate(90, X) * scale(dz, dz, dx) * unitsolidcylinder );
58   if (arrow1 != 0)
59     s.append( shift(0, -radius+1.5*dx, 0) * rotate(90, X) * carrow(1.3 * dz, 0.5, 0., 90., arrow1) );
61   if(arrow2 != 0)
62     s.append( shift(0, 0, -hight+radius/5+.5) * carrow(.8*radius, .5, 0, 90, arrow2) );
64   return s;
67 surface detector_arm(real length, real radius, int arrow1)
69   surface s;
70   real alpha = 0.1;
71   real dx = alpha * radius;
72   real dz = radius*sqrt(alpha*(2-alpha));
74   s.append( shift(-dz, -radius+dx+.1, -dz) * scale(length+dz, dx, 2*dz) * unitcube );
75   s.append( shift(length, -radius+dx+.2, -dz) * scale(-dx, radius-dx-.2, 2*dz) * unitcube );
76   s.append( shift(length-dx, 0, 0) * rotate(90, Y) * scale(dz, dz, dx) * unitsolidcylinder );
78   if(arrow1 != 0)
79     s.append( shift(0, -radius+1.5dx,0) * rotate(90, X) * carrow(1.3 * dz, 0.5, 0., 90., arrow1) );
81   return s;
84 surface sample_holder(real radius, int arrow1)
86   surface s;
87   real alpha = 0.1;
88   real dx = alpha * radius;
89   real dz = radius*sqrt(alpha*(2-alpha));
91   s.append( shift(0, -.8*(radius-dx), 0) * rotate(90, X) * scale(dz/2, dz/2, 0.15*(radius-dx)) *unitsolidcylinder );
92   s.append( shift(0, -.8*(radius-dx), 0) * rotate(90, X) * scale(dz, dz, dx) *shift(-.5, -.5, -1) * unitcube );
94   if(arrow1 != 0)
95     s.append( shift(0, -.8*(radius-dx)+dx, 0) * rotate(90, X) * carrow(0.15*(radius-dx), .3, 0, 270, arrow1) );
97   return s;
100 /*************/
101 /* Eulerians */
102 /*************/
104 surface support_e4cv(real hight, real detector, real sample)
106   surface s;
107   s.append( _support(hight, detector, 0, 0, true) );
108   s.append( _support(hight, sample, 1, 0, false) );
110   return s;
113 surface chi_circle(real radius, int arrow1)
115   surface s;
116   real alpha = 0.1;
117   real dx = alpha * radius;
118   real dz = radius*sqrt(alpha*(2-alpha));
120   // create a revolution surface
121   triple p1 = (radius-dx-.1)*Y-(dz/2)*X;
122   triple p2 = p1 + dz*X;
123   triple p3 = p2 - (.1*(radius-dx-.1) * Y);
124   triple p4 = p3 - dz*X;
125   path3 p= p1--p2--p3--p4--cycle;
127   s.append( surface(O, p, X) );
129   if(arrow1 != 0)
130     s.append( rotate(90, Y) * rotate(-90, Z) * carrow(.7 * (radius-dx-.1), .5, -90, 90, arrow1) );
132   return s;
135 /*********/
136 /* Kappa */
137 /*********/
139 surface support_k4cv(real hight, real detector, real sample)
141   surface s;
142   s.append( _support(hight, detector, 0, 0, true) );
143   s.append( _support(hight, sample, 0, 0, false) );
145   return s;
148 surface komega_circle(real radius, int arrow1, real kalpha=50)
150   surface s;
151   real alpha = 0.1;
152   real dx = alpha * radius;
153   real dz = radius*sqrt(alpha*(2-alpha));
154   real hight = radius * sin(radians(kalpha) / 2);
156   s.append(shift(-dz, -radius+dx, -hight) * scale(2*dz, dx, 2 * hight) * unitcube);
157   s.append(rotate(kalpha, X) * shift(-dz, -radius+dx, -hight) * scale(2*dz, dx, 2 * hight) * unitcube);
158   
159   if(arrow1 != 0)
160     s.append( shift(0, -radius+1.5dx,0) * rotate(90, X) * carrow(1.3 * dz, 0.5, 0., 90., arrow1) );
162   return s;
165 surface kappa_circle(real radius, int arrow1, real kalpha=50)
167   surface s;
168   real alpha = 0.1;
169   real dx = alpha * radius;
170   real dz = radius*sqrt(alpha*(2-alpha));
171   real hight = (radius-dx) * sin(radians(kalpha) / 2);
173   s.append(shift(-dz, -radius+dx+dx, -hight) * scale(2*dz, dx, 2 * hight) * unitcube);
174   s.append(rotate(kalpha, X) * shift(-dz, -radius+dx+dx, -hight) * scale(2*dz, dx, 2 * hight) * unitcube);
175   
176   if(arrow1 != 0)
177     s.append( rotate(kalpha, X) * shift(0, -radius+dx+dx+dx, 0) * rotate(90, X) * carrow(.6*dz, .3, 0, 270, arrow1) );
179   return s;