Logo ROOT  
Reference Guide
tornado.C File Reference

Detailed Description

View in nbviewer Open in SWAN Show 3-d polymarker.

void tornado() {
gBenchmark->Start("tornado");
double PI = 3.141592653;
int d = 16;
int numberOfPoints=200;
int numberOfCircles=40;
// create and open a canvas
TCanvas *sky = new TCanvas( "sky", "Tornado", 300, 10, 700, 500 );
sky->SetFillColor(14);
// creating view
TView *view = TView::CreateView(1,0,0);
float range = numberOfCircles*d;
view->SetRange( 0, 0, 0, 4.0*range, 2.0*range, range );
for( int j = d; j < numberOfCircles*d; j += d ) {
// create a PolyMarker3D
TPolyMarker3D *pm3d = new TPolyMarker3D( numberOfPoints );
float x, y, z;
// set points
for( int i = 1; i < numberOfPoints; i++ ) {
float csin = sin(2*PI / (double)numberOfPoints * (double)i) + 1;
float ccos = cos(2*PI / (double)numberOfPoints * (double)i) + 1;
float esin = sin(2*PI / (double)(numberOfCircles*d) * (double)j) + 1;
x = j * ( csin + esin );
y = j * ccos;
z = j;
pm3d->SetPoint( i, x, y, z );
}
// set marker size, color & style
pm3d->SetMarkerSize( 1 );
pm3d->SetMarkerColor( 2 + ( d == ( j & d ) ) );
pm3d->SetMarkerStyle( 3 );
//draw
pm3d->Draw();
}
char timeStr[60];
gBenchmark->Show("tornado");
Float_t ct = gBenchmark->GetCpuTime("tornado");
sprintf( timeStr, "Execution time: %g sec.", ct);
TPaveText *text = new TPaveText( 0.1, 0.81, 0.9, 0.97 );
text->SetFillColor( 42 );
text->AddText("ROOT example: tornado.C");
text->AddText(timeStr);
text->Draw();
sky->Update();
}
Author
Rene Brun

Definition in file tornado.C.

PI
#define PI
Definition: SpecFuncMathCore.cxx:23
TView::SetRange
virtual void SetRange(const Double_t *min, const Double_t *max)=0
TBenchmark::Start
virtual void Start(const char *name)
Starts Benchmark with the specified name.
Definition: TBenchmark.cxx:172
Float_t
float Float_t
Definition: RtypesCore.h:57
sin
double sin(double)
x
Double_t x[n]
Definition: legend1.C:17
cos
double cos(double)
tornado
Definition: tornado.py:1
text
TText * text
Definition: entrylist_figure1.C:10
TView
Definition: TView.h:25
TPolyMarker3D::Draw
virtual void Draw(Option_t *option="")
Draws 3-D polymarker with its current attributes.
Definition: TPolyMarker3D.cxx:265
TPolyMarker3D
Definition: TPolyMarker3D.h:32
gBenchmark
R__EXTERN TBenchmark * gBenchmark
Definition: TBenchmark.h:59
y
Double_t y[n]
Definition: legend1.C:17
TView::CreateView
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:27
TBenchmark::GetCpuTime
Float_t GetCpuTime(const char *name)
Returns Cpu time used by Benchmark name.
Definition: TBenchmark.cxx:117
TPolyMarker3D::SetPoint
void SetPoint(Int_t n, Double_t x, Double_t y, Double_t z)
Set point n to x, y, z.
Definition: TPolyMarker3D.cxx:558
TObject::Draw
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:197
TCanvas
Definition: TCanvas.h:23
TCanvas::Update
virtual void Update()
Update canvas pad buffers.
Definition: TCanvas.cxx:2500
d
#define d(i)
Definition: RSha256.hxx:120
TPaveText
Definition: TPaveText.h:21
TBenchmark::Show
virtual void Show(const char *name)
Stops Benchmark name and Prints results.
Definition: TBenchmark.cxx:155