Logo ROOT  
Reference Guide
glvox1.C File Reference

Detailed Description

This macro demonstrates how to use "glcol" option for TH3.

void glvox1()
{
//Create and fill TH3.
const UInt_t nX = 30;
const Double_t xMin = -1., xMax = 1., xStep = (xMax - xMin) / (nX - 1);
const UInt_t nY = 30;
const Double_t yMin = -1., yMax = 1., yStep = (yMax - yMin) / (nY - 1);
const UInt_t nZ = 30;
const Double_t zMin = -1., zMax = 1., zStep = (zMax - zMin) / (nZ - 1);
TH3F *hist = new TH3F("glvoxel", "glvoxel", 30, -1., 1., 30, -1., 1., 30, -1., 1.);
//Fill the histogram to create a "sphere".
for (UInt_t i = 0; i < nZ; ++i) {
const Double_t z = zMin + i * zStep;
for (UInt_t j = 0; j < nY; ++j) {
const Double_t y = yMin + j * yStep;
for (UInt_t k = 0; k < nX; ++k) {
const Double_t x = xMin + k * xStep;
const Double_t val = 1. - (x * x + y * y + z * z);
hist->SetBinContent(k + 1, j + 1, i + 1, val);
}
}
}
hist->Draw("glcol");
}
Author
Timur Pocheptsov

Definition in file glvox1.C.

TStyle::SetCanvasPreferGL
void SetCanvasPreferGL(Bool_t prefer=kTRUE)
Definition: TStyle.h:325
TH3::SetBinContent
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content.
Definition: TH3.cxx:3252
x
Double_t x[n]
Definition: legend1.C:17
gStyle
R__EXTERN TStyle * gStyle
Definition: TStyle.h:412
UInt_t
unsigned int UInt_t
Definition: RtypesCore.h:46
y
Double_t y[n]
Definition: legend1.C:17
TH3F
3-D histogram with a float per channel (see TH1 documentation)}
Definition: TH3.h:267
Double_t
double Double_t
Definition: RtypesCore.h:59
TH1::Draw
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Definition: TH1.cxx:2997