[ROOT] Displaying contours on a surface plot

From: Andreas Zoglauer (zog@ipp.mpg.de)
Date: Thu Mar 18 2004 - 16:15:48 MET


Hello Rooters!

I have the following probably challenging problem:

I want to draw a 2D surface plot (SURF2 or SURF4) and add (black) 
contour lines on the surface NOT above like in SURF3.

Here is an example with shows what I want to do:

Contour()
{
   gROOT->Reset();

   int NBins = 50;
   double d = 2;

   TH2F* h2 = new TH2F("h2", "h2", NBins, -d, d, NBins, -d, d);
   for (int bx = 1;  bx <= NBins; ++bx) {
     for (int by = 1;  by <= NBins; ++by) {
       double x = h2->GetXaxis()->GetBinCenter(bx);
       double y = h2->GetYaxis()->GetBinCenter(by);
       h2->SetBinContent(bx, by, exp(-x*x)*exp(-y*y));
     }
   }

   TCanvas *c1=new TCanvas("c1","c1",600,600);
   h2->Draw("SURF4");

   int LineBins = 100;
   TPolyLine3D *l = 0;
   for (double h = 0; h < 0.9*d; h+= d/20.0) {
     l = new TPolyLine3D(LineBins);
     for (int e = 0; e < LineBins; ++e) {
       Double_t Angle = e*2*TMath::Pi()/LineBins;
       l->SetPoint(e, h*cos(Angle), h*sin(Angle), exp(-h*h));
     }
     l->Draw("SAME");
   }

   c1->Update();
}

So my questions are:
1. Is there an easy way to do this in ROOT avoiding the calculation of 
the PolyLines?
2. If not, how can I hide/not draw the unvisible/hidden part of the 
polyline??


Thanks,
Andreas



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:06 MET