ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
tornado.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_graphics
3 /// Show 3-d polymarker.
4 ///
5 /// \macro_image
6 /// \macro_code
7 ///
8 /// \author Rene Brun
9 
10 void tornado() {
11  gBenchmark->Start("tornado");
12 
13  double PI = 3.141592653;
14  int d = 16;
15  int numberOfPoints=200;
16  int numberOfCircles=40;
17 
18  // create and open a canvas
19  TCanvas *sky = new TCanvas( "sky", "Tornado", 300, 10, 700, 500 );
20  sky->SetFillColor(14);
21 
22  // creating view
23  TView *view = TView::CreateView(1,0,0);
24  float range = numberOfCircles*d;
25  view->SetRange( 0, 0, 0, 4.0*range, 2.0*range, range );
26 
27  for( int j = d; j < numberOfCircles*d; j += d ) {
28 
29  // create a PolyMarker3D
30  TPolyMarker3D *pm3d = new TPolyMarker3D( numberOfPoints );
31 
32  float x, y, z;
33 
34  // set points
35  for( int i = 1; i < numberOfPoints; i++ ) {
36  float csin = sin(2*PI / (double)numberOfPoints * (double)i) + 1;
37  float ccos = cos(2*PI / (double)numberOfPoints * (double)i) + 1;
38  float esin = sin(2*PI / (double)(numberOfCircles*d) * (double)j) + 1;
39  x = j * ( csin + esin );
40  y = j * ccos;
41  z = j;
42  pm3d->SetPoint( i, x, y, z );
43  }
44 
45  // set marker size, color & style
46  pm3d->SetMarkerSize( 1 );
47  pm3d->SetMarkerColor( 2 + ( d == ( j & d ) ) );
48  pm3d->SetMarkerStyle( 3 );
49 
50  //draw
51  pm3d->Draw();
52  }
53 
54  char timeStr[60];
55  gBenchmark->Show("tornado");
56 
57  Float_t ct = gBenchmark->GetCpuTime("tornado");
58  sprintf( timeStr, "Execution time: %g sec.", ct);
59 
60  TPaveText *text = new TPaveText( 0.1, 0.81, 0.9, 0.97 );
61  text->SetFillColor( 42 );
62  text->AddText("ROOT example: tornado.C");
63  text->AddText(timeStr);
64  text->Draw();
65  sky->Update();
66 }
virtual void Draw(Option_t *option="")
Draw this pavetext with its current attributes.
Definition: TPaveText.cxx:211
float Float_t
Definition: RtypesCore.h:53
See TView3D.
Definition: TView.h:36
virtual TText * AddText(Double_t x1, Double_t y1, const char *label)
Add a new Text line to this pavetext at given coordinates.
Definition: TPaveText.cxx:160
int numberOfPoints
Definition: tornado.py:12
virtual void SetRange(const Double_t *min, const Double_t *max)=0
virtual void Show(const char *name)
Stops Benchmark name and Prints results.
Definition: TBenchmark.cxx:155
double cos(double)
virtual void Start(const char *name)
Starts Benchmark with the specified name.
Definition: TBenchmark.cxx:172
Double_t x[n]
Definition: legend1.C:17
int d
Definition: tornado.py:11
virtual void SetMarkerColor(Color_t mcolor=1)
Definition: TAttMarker.h:51
Float_t GetCpuTime(const char *name)
Returns Cpu time used by Benchmark name.
Definition: TBenchmark.cxx:117
tuple esin
Definition: tornado.py:34
double sin(double)
Float_t z[5]
Definition: Ifit.C:16
tuple ccos
Definition: tornado.py:33
virtual void SetFillColor(Color_t fcolor)
Definition: TAttFill.h:50
R__EXTERN TBenchmark * gBenchmark
Definition: TBenchmark.h:63
virtual void SetMarkerStyle(Style_t mstyle=1)
Definition: TAttMarker.h:53
virtual void Draw(Option_t *option="")
Draws 3-D polymarker with its current attributes.
virtual void SetMarkerSize(Size_t msize=1)
Definition: TAttMarker.h:54
void SetPoint(Int_t n, Double_t x, Double_t y, Double_t z)
Set point n to x, y, z.
The Canvas class.
Definition: TCanvas.h:48
A Pave (see TPave) with text, lines or/and boxes inside.
Definition: TPaveText.h:35
Double_t y[n]
Definition: legend1.C:17
static TView * CreateView(Int_t system=1, const Double_t *rmin=0, const Double_t *rmax=0)
Create a concrete default 3-d view via the plug-in manager.
Definition: TView.cxx:36
A 3D polymarker.
Definition: TPolyMarker3D.h:40
virtual void Update()
Update canvas pad buffers.
Definition: TCanvas.cxx:2179