ROOT   Reference Guide
robot.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_geom
3/// Drawing a famous Korean robot, TaekwonV, using ROOT geometry class.
4///
5/// Reviewed by Sunman Kim (sunman98@hanmail.net)
6/// Supervisor: Prof. Inkyu Park (icpark@physics.uos.ac.kr)
7///
8/// How to run: .x robot.C in ROOT terminal, then use OpenGL
9///
10/// This macro was created for the evaluation of Computational Physics course in 2006.
11/// We thank to Prof. Inkyu Park for his special lecture on ROOT and to all of ROOT team
12///
13/// \image html geom_robot.png width=500px
14/// \macro_code
15///
16/// \author Jin Hui Hwang, Dept. of Physics, Univ. of Seoul
17
18#include "TGeoManager.h"
19
20void robot()
21{
22
23
24 TGeoManager *Robot = new TGeoManager("Robot","This is Taegwon V");
25
26 TGeoMaterial *vacuum=new TGeoMaterial("vacuum",0,0,0);
27 TGeoMaterial *Fe=new TGeoMaterial("Fe",55.845,26,7.87);
28
29 TGeoMedium *Air=new TGeoMedium("Vacuum",0,vacuum);
30 TGeoMedium *Iron=new TGeoMedium("Iron",1,Fe);
31
32 // create volume
33
34 TGeoVolume *top=Robot->MakeBox("top",Air,1000,1000,1000);
35 Robot->SetTopVolume(top);
36 Robot->SetTopVisible(0);
37 // If you want to see the boundary, please input the number, 1 instead of 0.
38 // Like this, geom->SetTopVisible(1);
39
40
41
43 TGeoVolume *Band=Robot->MakeEltu("Band",Iron,20,20,2.5);
44 Band->SetLineColor(12);
45 Band->SetFillColor(12);
46 TGeoVolume *Band_b=Robot->MakeSphere("Band_b",Iron,0,2,0,180,180,360);
47 Band_b->SetLineColor(2);
48 Band_b->SetFillColor(2);
52 TGeoVolume *Horn=Robot->MakeSphere("Horn",Iron,0,10,60,180,240,300);
53
56 float Phi = 3.14;
57 int N = 10;
58
59 for (int i=0; i<=N;i++){
61 new TGeoRotation("R1",-90+(360/N*i),-90,90)));
62 }
64
65 char name[50];
66 float pcs = 30;
67 for (int i=1; i<pcs; i++){
68 sprintf(name,"Horn%d",i);
69 Horn=Robot->MakeSphere(name,Iron,
70 10- 10/pcs*i ,10,180-(120/pcs)*i,180-((120/pcs) * (i-1)),240,300);
71 Horn->SetLineColor(2);
72 Horn->SetFillColor(2);
75 }
76
77 // face
78 TGeoVolume *Migan=Robot->MakeGtra("Migan",Iron,3,0,0,0,3,2,11,0,3,3,11,0);
79 Migan->SetLineColor(17);
80 Migan->SetFillColor(17);
81 TGeoVolume *Ko=Robot->MakeGtra("Ko",Iron,7,0,0,0,3,1,5,0,3,2,5,0);
82 Ko->SetLineColor(17);
83 Ko->SetFillColor(17);
84 TGeoVolume *Ko_m=Robot->MakeBox("Ko_m",Iron,2,8,4);
85 Ko_m->SetLineColor(17);
86 Ko_m->SetFillColor(17);
87 TGeoVolume *Bol_1=Robot->MakeBox("Bol_1",Iron,7,5.5,7);
88 Bol_1->SetLineColor(17);
89 Bol_1->SetFillColor(17);
90 TGeoVolume *Bol_2=Robot->MakeGtra("Bol_2",Iron,1,0,0,0,7,0,9,0,7,0,9,0);
91 Bol_2->SetLineColor(17);
92 Bol_2->SetFillColor(17);
93 TGeoVolume *Noon=Robot->MakeBox("Noon",Iron,1,10,5);
94 Noon->SetLineColor(12);
95 Noon->SetFillColor(12);
96 TGeoVolume *Tuck=Robot->MakeBox("Tuck",Iron,2,10,5.5);
97 Tuck->SetLineColor(2);
98 Tuck->SetFillColor(2);
99 TGeoVolume *Tuck_1=Robot->MakeBox("Tuck_1",Iron,2,9,1);
100 Tuck_1->SetLineColor(2);
101 Tuck_1->SetFillColor(2);
102 TGeoVolume *Tuck_2=Robot->MakeBox("Tuck_2",Iron,3,1,14);
103 Tuck_2->SetLineColor(2);
104 Tuck_2->SetFillColor(2);
105 TGeoVolume *Tuck_j=Robot->MakeSphere("Tuck_j",Iron,0,3.5,0,180,0,360);
106 Tuck_j->SetLineColor(5);
107 Tuck_j->SetFillColor(5);
108 TGeoVolume *Ear=Robot->MakeCons("Ear",Iron,1,0,3,0,3,0,360);
109 Ear->SetLineColor(5);
110 Ear->SetFillColor(5);
111 TGeoVolume *Ear_2=Robot->MakeCone("Ear_2",Iron,5,0,0,0,3);
112 Ear_2->SetLineColor(5);
113 Ear_2->SetFillColor(5);
114
115 // drawing face
128 for (int i=0; i<10;i++) {
131 }
139
140
141 for (int i=1; i<28; i+=1) {
142 float a=i*0.2;
143 TGeoVolume *Hear=Robot->MakeCons("Hear",Iron,3,13+a,16+a,13+a,16+a,-60-a,60+a);
144 if (i<27) {
145 Hear->SetLineColor(12);
146 Hear->SetFillColor(12);
147 }
148 else {
149 Hear->SetLineColor(2);
150 Hear->SetFillColor(2);
151 }
153 }
154 for (int i=1; i<28; i+=1) {
155 float a=i*0.2;
156 TGeoVolume *Hear=Robot->MakeCons("Hear",Iron,3,13+a,16+a,13+a,16+a,-70-a,-60-a);
157 Hear->SetLineColor(2);
158 Hear->SetFillColor(2);
160 }
161 for (int i=1; i<28; i+=1) {
162 float a=i*0.2;
163 TGeoVolume *Hear=Robot->MakeCons("Hear",Iron,3,13+a,16+a,13+a,16+a,60+a,70+a);
164 Hear->SetLineColor(2);
165 Hear->SetFillColor(2);
167 }
168
169 // neck
170 TGeoVolume *Mock=Robot->MakeTrd2("Mock",Iron,1,1,7,6.5,20);
171 Mock->SetLineColor(17);
172 Mock->SetFillColor(17);
173 TGeoVolume *Mock_1=Robot->MakeTrd2("Mock_1",Iron,1,1,6,5,20);
174 Mock_1->SetLineColor(17);
175 Mock_1->SetFillColor(17);
176 TGeoVolume *Mock_s=Robot->MakeTrd2("Mock_s",Iron,1,1,5,4.5,20);
177 Mock_s->SetLineColor(17);
178 Mock_s->SetFillColor(17);
179
180 // drawing neck
187
188
189 // chest
190 TGeoVolume *Gasem=Robot->MakeBox("Gasem",Iron,16,50,20);
191 Gasem->SetLineColor(12);
192 Gasem->SetFillColor(12);
193 TGeoVolume *Gasem_b1=Robot->MakeSphere("Gasem_b1",Iron,0,15,0,180,0,360);
194 Gasem_b1->SetLineColor(12);
195 Gasem_b1->SetFillColor(12);
196 TGeoVolume *Gasem_b2=Robot->MakeSphere("Gasem_b2",Iron,0,13,0,180,0,360);
197 Gasem_b2->SetLineColor(12);
198 Gasem_b2->SetFillColor(12);
199 TGeoVolume *Gasem_1=Robot->MakeEltu("Gasem_1",Iron,13,13,20);
200 Gasem_1->SetLineColor(12);
201 Gasem_1->SetFillColor(12);
202 TGeoVolume *Gasem_2=Robot->MakeEltu("Gasem_2",Iron,13,13,19);
203 Gasem_2->SetLineColor(12);
204 Gasem_2->SetFillColor(12);
205 TGeoVolume *Gasem_3=Robot->MakeCone("Gasem_3",Iron,19,0,13,0,15);
206 Gasem_3->SetLineColor(12);
207 Gasem_3->SetFillColor(12);
208 TGeoVolume *Gasem_4=Robot->MakeEltu("Gasem_4",Iron,15,15,16);
209 Gasem_4->SetLineColor(12);
210 Gasem_4->SetFillColor(12);
211 TGeoVolume *Gasem_5=Robot->MakeEltu("Gasem_5",Iron,13,13,16);
212 Gasem_5->SetLineColor(12);
213 Gasem_5->SetFillColor(12);
214 TGeoVolume *Gasem_m1=Robot->MakeBox("Gasem_m1",Iron,19,19,5);
215 Gasem_m1->SetLineColor(12);
216 Gasem_m1->SetFillColor(12);
217 TGeoVolume *Gasem_m2=Robot->MakeTrd2("Gasem_m2",Iron,13,15,2,2,19);
218 Gasem_m2->SetLineColor(12);
219 Gasem_m2->SetFillColor(12);
220 TGeoVolume *V=Robot->MakeTrd2("V",Iron,2,2,22,30,4);
221 V->SetLineColor(2);
222 V->SetFillColor(2);
223 TGeoVolume *V_m=Robot->MakeBox("V_m",Iron,2,7,1);
224 V_m->SetLineColor(2);
225 V_m->SetFillColor(2);
226
227 // drawing chest
279
280 // abdomen
281 TGeoVolume *Bea=Robot->MakeEltu("Bea",Iron,20,37,25);
282 Bea->SetLineColor(17);
283 Bea->SetFillColor(17);
284 TGeoVolume *Bea_d=Robot->MakeEltu("Bea_d",Iron,21,36,5);
285 Bea_d->SetLineColor(12);
286 Bea_d->SetFillColor(12);
287 TGeoVolume *Beakop=Robot->MakeEltu("Beakop",Iron,15,25,5);
288 Beakop->SetLineColor(10);
289 Beakop->SetFillColor(10);
290
291 // drawing abdomen
295
296 // Gungdi
297 TGeoVolume *Gungdi=Robot->MakeEltu("Gungdi",Iron,25,50,18);
298 Gungdi->SetLineColor(12);
299 Gungdi->SetFillColor(12);
300 TGeoVolume *Gungdi_d=Robot->MakeEltu("Gungdi_d",Iron,5,5,5);
301 Gungdi_d->SetLineColor(2);
302 Gungdi_d->SetFillColor(2);
303
304 // drawing Gungdi
306 for (int i=0; i<30; i++) {
307 TGeoVolume *Gungdi_j=Robot->MakeEltu("Gungdi_j",Iron,24-0.2*i,49-0.5*i,1);
308 Gungdi_j->SetLineColor(12);
309 Gungdi_j->SetFillColor(12);
311 }
312 for (int i=0; i<40; i++) {
313 if (i<16) {
314 TGeoVolume *Gungdi_h=Robot->MakeEltu("Gungdi_h",Iron,24-0.1*i,49-0.3*i,1);
315 Gungdi_h->SetLineColor(12);
316 Gungdi_h->SetFillColor(12);
318 }
319 else {
320 TGeoVolume *Gungdi_h=Robot->MakeEltu("Gungdi_h",Iron,27-0.3*i,52-0.5*i,1);
321 Gungdi_h->SetLineColor(12);
322 Gungdi_h->SetFillColor(12);
324 }
325 }
330
331 // feet
332 TGeoVolume *Jang=Robot->MakeEltu("Jang",Iron,18,18,50);
333 Jang->SetLineColor(17);
334 Jang->SetFillColor(17);
335 TGeoVolume *Jong=Robot->MakeEltu("Jong",Iron,22,22,50);
336 Jong->SetLineColor(12);
337 Jong->SetFillColor(12);
338 TGeoVolume *Bal=Robot->MakeSphere("Bal",Iron,0,22,0,180,180,360);
339 Bal->SetLineColor(12);
340 Bal->SetFillColor(12);
341
342 // drawing Dary
347 for (int i=0; i<30; i++) {
348 TGeoVolume *Mu=Robot->MakeCons("Mu",Iron,1,0,22.1,0,22.1,120+2*i,-120-2*i);
349 Mu->SetLineColor(4);
350 Mu->SetFillColor(4);
353
354 }
357
358 // arms
359 TGeoVolume *S=Robot->MakeSphere("S",Iron,0,25,0,180,180,360);
360 S->SetLineColor(17);
361 S->SetFillColor(17);
362 TGeoVolume *S_1=Robot->MakeSphere("S_1",Iron,0,15,0,180,0,360);
363 S_1->SetLineColor(17);
364 S_1->SetFillColor(17);
365 TGeoVolume *Pal=Robot->MakeEltu("Pal",Iron,15,15,30);
366 Pal->SetLineColor(17);
367 Pal->SetFillColor(17);
368 TGeoVolume *Fal=Robot->MakeEltu("Fal",Iron,17,17,30);
369 Fal->SetLineColor(4);
370 Fal->SetFillColor(4);
371 TGeoVolume *Bbul=Robot->MakeCone("Bbul",Iron,8,0,0,0,5);
372 Bbul->SetLineColor(17);
373 Bbul->SetFillColor(17);
374
375 // drawing arms
388
389 // hands
390 TGeoVolume *Son_d=Robot->MakeBox("Son_d",Iron,15,15,7);
391 Son_d->SetLineColor(4);
392 Son_d->SetFillColor(4);
393 TGeoVolume *Son_g=Robot->MakeBox("Son_g",Iron,4,10,4);
394 Son_g->SetLineColor(4);
395 Son_g->SetFillColor(4);
396 TGeoVolume *Son_g1=Robot->MakeBox("Son_g1",Iron,6,6,6);
397 Son_g1->SetLineColor(4);
398 Son_g1->SetFillColor(4);
399 TGeoVolume *Son_g2=Robot->MakeBox("Son_g2",Iron,8,3,3);
400 Son_g2->SetLineColor(4);
401 Son_g2->SetFillColor(4);
402 TGeoVolume *Last_b=Robot->MakeCone("Last_b",Iron,10,0,0,0,4);
403 Last_b->SetLineColor(17);
404 Last_b->SetFillColor(17);
405 TGeoVolume *Last=Robot->MakeSphere("Last",Iron,0,3,0,180,0,360);
406 Last->SetLineColor(2);
407 Last->SetFillColor(2);
408
409 //drawing hands
411 for (int i=0; i<4; i++) {
413 }
414 for (int i=0; i<4; i++) {
416 }
420 for (int i=0; i<4; i++) {
422 }
423 for (int i=0; i<4; i++) {
425 }
440
441for (int i=1; i<20; i+=1) {
442 if (i<7) {
443 TGeoVolume *Effect=Robot->MakeCons("Effect",Iron,3,20/sin(i),21/sin(i),20/sin(i),21/sin(i),0,70);
444 Effect->SetLineColor(9);
445 Effect->SetFillColor(9);
447 }
448 if (6<i && i<10) {
449 TGeoVolume *Effect=Robot->MakeCons("Effect",Iron,5,20/sin(i),21/sin(i),20/sin(i),21/sin(i),50,120);
450 Effect->SetLineColor(38);
451 Effect->SetFillColor(38);
453 }
454 if (9<i && i<20) {
455 TGeoVolume *Effect=Robot->MakeCons("Effect",Iron,4,20/sin(i),21/sin(i),20/sin(i),21/sin(i),200,330);
456 Effect->SetLineColor(33);
457 Effect->SetFillColor(33);
459 }
460}
461
462
463 //close geometry
464 top->SetVisibility(0);
465 Robot->CloseGeometry();
466
467 // in GL viewer
468 top->Draw("ogl");
469}
#define N
char name[80]
Definition: TGX11.cxx:110
double cos(double)
double sin(double)
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
Class describing rotation + translation.
Definition: TGeoMatrix.h:292
The manager class for any TGeo geometry.
Definition: TGeoManager.h:45
TGeoVolume * MakeCone(const char *name, TGeoMedium *medium, Double_t dz, Double_t rmin1, Double_t rmax1, Double_t rmin2, Double_t rmax2)
Make in one step a volume pointing to a cone shape with given medium.
TGeoVolume * MakeCons(const char *name, TGeoMedium *medium, Double_t dz, Double_t rmin1, Double_t rmax1, Double_t rmin2, Double_t rmax2, Double_t phi1, Double_t phi2)
Make in one step a volume pointing to a cone segment shape with given medium.
void CloseGeometry(Option_t *option="d")
Closing geometry implies checking the geometry validity, fixing shapes with negative parameters (run-...
TGeoVolume * MakeTrd2(const char *name, TGeoMedium *medium, Double_t dx1, Double_t dx2, Double_t dy1, Double_t dy2, Double_t dz)
Make in one step a volume pointing to a TGeoTrd2 shape with given medium.
TGeoVolume * MakeGtra(const char *name, TGeoMedium *medium, Double_t dz, Double_t theta, Double_t phi, Double_t twist, Double_t h1, Double_t bl1, Double_t tl1, Double_t alpha1, Double_t h2, Double_t bl2, Double_t tl2, Double_t alpha2)
Make in one step a volume pointing to a twisted trapezoid shape with given medium.
TGeoVolume * MakeBox(const char *name, TGeoMedium *medium, Double_t dx, Double_t dy, Double_t dz)
Make in one step a volume pointing to a box shape with given medium.
TGeoVolume * MakeSphere(const char *name, TGeoMedium *medium, Double_t rmin, Double_t rmax, Double_t themin=0, Double_t themax=180, Double_t phimin=0, Double_t phimax=360)
Make in one step a volume pointing to a sphere shape with given medium.
void SetTopVolume(TGeoVolume *vol)
Set the top volume and corresponding node as starting point of the geometry.
void SetTopVisible(Bool_t vis=kTRUE)
make top volume visible on screen
TGeoVolume * MakeEltu(const char *name, TGeoMedium *medium, Double_t a, Double_t b, Double_t dz)
Make in one step a volume pointing to a tube shape with given medium.
Base class describing materials.
Definition: TGeoMaterial.h:36
Media are used to store properties related to tracking and which are useful only when using geometry ...
Definition: TGeoMedium.h:24
Class describing rotations.
Definition: TGeoMatrix.h:175
Class describing translations.
Definition: TGeoMatrix.h:122
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition: TGeoVolume.h:49
virtual void SetVisibility(Bool_t vis=kTRUE)
set visibility of this volume
virtual void AddNodeOverlap(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=0, Option_t *option="")
Add a TGeoNode to the list of nodes.
Definition: TGeoVolume.cxx:997
virtual void Draw(Option_t *option="")
draw top volume according to option
virtual void SetLineColor(Color_t lcolor)
Set the line color.
RooArgSet S(const RooAbsArg &v1)
auto * a
Definition: textangle.C:12