Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
boxset_cones.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_eve
3/// Demonstrates usage of 'cone' mode in TEveBoxSet class.
4///
5/// \image html eve_boxset_cones.png
6/// \macro_code
7///
8/// \author Alja Mrak-Tadel
9
10TEveBoxSet *boxset_cones(Float_t x = 0, Float_t y = 0, Float_t z = 0, Int_t num = 100, Bool_t register = kTRUE)
11{
13
14 using namespace TMath;
15
16 auto lines = new TEveStraightLineSet("StraightLines");
17 lines->SetLineColor(kYellow);
18 lines->SetLineWidth(2);
19
20 TRandom r(0);
21 auto pal = new TEveRGBAPalette(0, 500);
22 auto cones = new TEveBoxSet("ConeSet");
23 cones->SetPalette(pal);
25
26 Float_t a = 40; // max distance between cones
27 TEveVector dir, pos;
28 Float_t theta, phi, height, rad;
29 for (Int_t i = 0; i < num; ++i) {
30 theta = r.Uniform(0, TMath::Pi());
31 phi = r.Uniform(-TMath::Pi(), TMath::Pi());
32 height = r.Uniform(5, 15);
33 rad = r.Uniform(3, 5);
34 dir.Set(Cos(phi) * Cos(theta), Sin(phi) * Cos(theta), Sin(theta));
35 dir *= height;
36 pos.Set(r.Uniform(-a, a), r.Uniform(-a, a), r.Uniform(-a, a));
37
38 cones->AddCone(pos, dir, rad);
39 cones->DigitValue(r.Uniform(0, 500));
40
41 // draw axis line 30% longer than cone height
42 end = pos + dir * 1.3f;
43 end.fZ);
44 }
45
46 // by default cone cap not drawn
47 if (r.Integer(2) > 0)
48 cones->SetDrawConeCap(kTRUE);
49
50 cones->RefitPlex();
51 TEveTrans &t = cones->RefMainTrans();
52 t.SetPos(x, y, z);
53
56
58
59 return cones;
60}
61
62TEveBoxSet *elliptic_boxset_cones(Float_t x = 0, Float_t y = 0, Float_t z = 0, Int_t num = 100, Bool_t register = kTRUE)
63{
65
66 using namespace TMath;
67
69
70 auto lines = new TEveStraightLineSet("StraightLines");
71 lines->SetLineColor(kYellow);
72 lines->SetLineWidth(2);
73
74 TRandom r(0);
75
76 auto cones = new TEveBoxSet("EllipticConeSet");
78
79 cones->SetPickable(kTRUE);
80
81 Float_t a = 40; // max distance between cones
82 TEveVector dir, pos;
83 Float_t theta, phi, height, rad;
84 for (Int_t i = 0; i < num; ++i) {
85 theta = r.Uniform(0, TMath::Pi());
86 phi = r.Uniform(-TMath::Pi(), TMath::Pi());
87 height = r.Uniform(5, 15);
88 rad = r.Uniform(3, 5);
89 dir.Set(Cos(phi) * Cos(theta), Sin(phi) * Cos(theta), Sin(theta));
90 dir *= height;
91 pos.Set(r.Uniform(-a, a), r.Uniform(-a, a), r.Uniform(-a, a));
92
93 cones->AddEllipticCone(pos, dir, rad, 0.5 * rad, r.Uniform(0, 360));
94 cones->DigitColor(r.Uniform(20, 255), r.Uniform(20, 255), r.Uniform(20, 255), r.Uniform(20, 255));
95
96 // draw axis line 30% longer than cone height
97 end = pos + dir * 1.3f;
98 end.fZ);
99 }
100
101 // by default cone cap not drawn
102 if (r.Integer(2) > 0)
103 cones->SetDrawConeCap(kTRUE);
104
105 cones->RefitPlex();
106 TEveTrans &t = cones->RefMainTrans();
107 t.SetPos(x, y, z);
108
111
113
114 return cones;
115}
#define a(i)
Definition RSha256.hxx:99
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
@ kYellow
Definition Rtypes.h:66
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TEveManager * gEve
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
Collection of 3D primitives (fixed-size boxes, boxes of different sizes, or arbitrary sexto-epipeds,...
Definition TEveBoxSet.h:22
@ kBT_EllipticCone
Definition TEveBoxSet.h:35
void AddElement(TEveElement *element, TEveElement *parent=nullptr)
Add an element.
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
void Redraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
A generic, speed-optimised mapping from value to RGBA color supporting different wrapping and range t...
Set of straight lines with optional markers along the lines.
TEveTrans is a 4x4 transformation matrix for homogeneous coordinates stored internally in a column-ma...
Definition TEveTrans.h:27
void SetPos(Double_t x, Double_t y, Double_t z)
Set position (base-vec 4).
void Set(const Float_t *v)
Definition TEveVector.h:82
This is the base class for the ROOT Random number generators.
Definition TRandom.h:27
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
TMath.
Definition TMathBase.h:35
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Definition TMath.h:598
constexpr Double_t Pi()
Definition TMath.h:37
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Definition TMath.h:592