Logo ROOT   6.18/05
Reference Guide
boxset_cones.C File Reference

Detailed Description

Demonstrates usage of 'cone' mode in TEveBoxSet class.

TEveBoxSet* boxset_cones(Float_t x=0, Float_t y=0, Float_t z=0,
Int_t num=100, Bool_t register=kTRUE)
{
using namespace TMath;
auto lines = new TEveStraightLineSet("StraightLines");
lines->SetLineColor(kYellow);
lines->SetLineWidth(2);
TRandom r(0);
auto pal = new TEveRGBAPalette(0, 500);
auto cones = new TEveBoxSet("ConeSet");
cones->SetPalette(pal);
cones->Reset(TEveBoxSet::kBT_Cone, kFALSE, 64);
Float_t a = 40; // max distance between cones
TEveVector dir, pos;
Float_t theta, phi, height, rad;
for (Int_t i=0; i<num; ++i) {
theta = r.Uniform(0,TMath::Pi());
phi = r.Uniform (-TMath::Pi(), TMath::Pi());
height = r.Uniform(5, 15);
rad = r.Uniform(3, 5);
dir.Set(Cos(phi)*Cos(theta), Sin(phi)*Cos(theta), Sin(theta));
dir *= height;
pos.Set(r.Uniform(-a,a), r.Uniform(-a, a), r.Uniform(-a, a));
cones->AddCone(pos, dir, rad);
cones->DigitValue(r.Uniform(0, 500));
// draw axis line 30% longer than cone height
TEveVector end = pos + dir*1.3f;
lines->AddLine(pos.fX, pos.fY, pos.fZ, end.fX, end.fY, end.fZ);
}
// by default cone cap not drawn
if (r.Integer(2)>0) cones->SetDrawConeCap(kTRUE);
cones->RefitPlex();
TEveTrans& t = cones->RefMainTrans();
t.SetPos(x, y, z);
gEve->AddElement(cones);
gEve->AddElement(lines);
return cones;
}
TEveBoxSet* elliptic_boxset_cones(Float_t x=0, Float_t y=0, Float_t z=0,
Int_t num=100, Bool_t register=kTRUE)
{
using namespace TMath;
auto lines = new TEveStraightLineSet("StraightLines");
lines->SetLineColor(kYellow);
lines->SetLineWidth(2);
TRandom r(0);
auto cones = new TEveBoxSet("EllipticConeSet");
cones->Reset(TEveBoxSet::kBT_EllipticCone, kTRUE, 64);
cones->SetPickable(kTRUE);
Float_t a = 40; // max distance between cones
TEveVector dir, pos;
Float_t theta, phi, height, rad;
for (Int_t i=0; i<num; ++i) {
theta = r.Uniform(0,TMath::Pi());
phi = r.Uniform (-TMath::Pi(), TMath::Pi());
height = r.Uniform(5, 15);
rad = r.Uniform(3, 5);
dir.Set(Cos(phi)*Cos(theta), Sin(phi)*Cos(theta), Sin(theta));
dir *= height;
pos.Set(r.Uniform(-a,a), r.Uniform(-a, a), r.Uniform(-a, a));
cones->AddEllipticCone(pos, dir, rad, 0.5*rad, r.Uniform(0,360));
cones->DigitColor(r.Uniform(20, 255), r.Uniform(20, 255),
r.Uniform(20, 255), r.Uniform(20, 255));
// draw axis line 30% longer than cone height
TEveVector end = pos + dir*1.3f;
lines->AddLine(pos.fX, pos.fY, pos.fZ, end.fX, end.fY, end.fZ);
}
// by default cone cap not drawn
if (r.Integer(2)>0) cones->SetDrawConeCap(kTRUE);
cones->RefitPlex();
TEveTrans& t = cones->RefMainTrans();
t.SetPos(x, y, z);
gEve->AddElement(cones);
gEve->AddElement(lines);
return cones;
}
ROOT::R::TRInterface & r
Definition: Object.C:4
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
float Float_t
Definition: RtypesCore.h:53
const Bool_t kTRUE
Definition: RtypesCore.h:87
@ kYellow
Definition: Rtypes.h:64
R__EXTERN TEveManager * gEve
Definition: TEveManager.h:243
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=0)
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)
Definition: TEveManager.h:168
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).
Definition: TEveTrans.cxx:507
void Set(const Float_t *v)
Definition: TEveVector.h:81
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
static constexpr double rad
TMath.
Definition: TMathBase.h:35
Double_t Cos(Double_t)
Definition: TMath.h:629
constexpr Double_t Pi()
Definition: TMath.h:38
Double_t Sin(Double_t)
Definition: TMath.h:625
auto * a
Definition: textangle.C:12
Author
Alja Mrak-Tadel

Definition in file boxset_cones.C.