Logo ROOT   6.12/07
Reference Guide
tornado.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_graphics
3 /// \notebook
4 /// Show 3-d polymarker.
5 ///
6 /// \macro_image
7 /// \macro_code
8 ///
9 /// \author Rene Brun
10 
11 void tornado() {
12  gBenchmark->Start("tornado");
13 
14  double PI = 3.141592653;
15  int d = 16;
16  int numberOfPoints=200;
17  int numberOfCircles=40;
18 
19  // create and open a canvas
20  TCanvas *sky = new TCanvas( "sky", "Tornado", 300, 10, 700, 500 );
21  sky->SetFillColor(14);
22 
23  // creating view
24  TView *view = TView::CreateView(1,0,0);
25  float range = numberOfCircles*d;
26  view->SetRange( 0, 0, 0, 4.0*range, 2.0*range, range );
27 
28  for( int j = d; j < numberOfCircles*d; j += d ) {
29 
30  // create a PolyMarker3D
31  TPolyMarker3D *pm3d = new TPolyMarker3D( numberOfPoints );
32 
33  float x, y, z;
34 
35  // set points
36  for( int i = 1; i < numberOfPoints; i++ ) {
37  float csin = sin(2*PI / (double)numberOfPoints * (double)i) + 1;
38  float ccos = cos(2*PI / (double)numberOfPoints * (double)i) + 1;
39  float esin = sin(2*PI / (double)(numberOfCircles*d) * (double)j) + 1;
40  x = j * ( csin + esin );
41  y = j * ccos;
42  z = j;
43  pm3d->SetPoint( i, x, y, z );
44  }
45 
46  // set marker size, color & style
47  pm3d->SetMarkerSize( 1 );
48  pm3d->SetMarkerColor( 2 + ( d == ( j & d ) ) );
49  pm3d->SetMarkerStyle( 3 );
50 
51  //draw
52  pm3d->Draw();
53  }
54 
55  char timeStr[60];
56  gBenchmark->Show("tornado");
57 
58  Float_t ct = gBenchmark->GetCpuTime("tornado");
59  sprintf( timeStr, "Execution time: %g sec.", ct);
60 
61  TPaveText *text = new TPaveText( 0.1, 0.81, 0.9, 0.97 );
62  text->SetFillColor( 42 );
63  text->AddText("ROOT example: tornado.C");
64  text->AddText(timeStr);
65  text->Draw();
66  sky->Update();
67 }
virtual void Draw(Option_t *option="")
Draw this pavetext with its current attributes.
Definition: TPaveText.cxx:234
float Float_t
Definition: RtypesCore.h:53
See TView3D.
Definition: TView.h:25
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:183
virtual void SetRange(const Double_t *min, const Double_t *max)=0
#define PI
virtual void Show(const char *name)
Stops Benchmark name and Prints results.
Definition: TBenchmark.cxx:157
double cos(double)
virtual void Start(const char *name)
Starts Benchmark with the specified name.
Definition: TBenchmark.cxx:174
Double_t x[n]
Definition: legend1.C:17
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Definition: TAttMarker.h:38
Float_t GetCpuTime(const char *name)
Returns Cpu time used by Benchmark name.
Definition: TBenchmark.cxx:119
double sin(double)
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
R__EXTERN TBenchmark * gBenchmark
Definition: TBenchmark.h:59
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
Definition: TAttMarker.h:40
virtual void Draw(Option_t *option="")
Draws 3-D polymarker with its current attributes.
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
Definition: TAttMarker.h:41
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:31
A Pave (see TPave) with text, lines or/and boxes inside.
Definition: TPaveText.h:21
TText * text
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:39
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
A 3D polymarker.
Definition: TPolyMarker3D.h:32
virtual void Update()
Update canvas pad buffers.
Definition: TCanvas.cxx:2248