incorrect scaling in TPGON

From: rhatcher@SLAC.stanford.edu
Date: Sat Apr 01 2000 - 00:18:26 MEST


There seems to be a error in the drawing of PGCON objects under 
ROOT 2.23/12 (and I believe it was wrong before that as well).  
Under GEANT3, PGON radii corresponded to the "radius of the circle 
tangent to the sides of the inner/outer polygon in the cross-section".
In other words the radius of the _inscribed_ circle.  

The "FillTableOfCoSin" method inherited from TPCON has recently been
overridden but the calculation is incorrect.  The resulting CoSin values
are scaled by the radii to determine the vertices of the polygon.
If "dphi1" (degrees) is the opening angle of the volume and "npdv" is the 
number of sides, then 
  angstep = pi/180 * dphi1 / npdv
and the relevant scale is:
    factor = 1/cos(angstep/2) 
which is the ratio of the circumscribed to inscribed radii.  
The TPCON does not scale by any additional factor (which is right for cones) 
but TPGON uses 1/sin(angstep) which is wrong.

-robert

The following macro will show the effect.  

=================================================

{
TGeometry *testgeom = new TGeometry("testgeom","test octogon");

Float_t size = 1.;
Float_t rin  = 0.;
Float_t rout, zmin, zmax;

// draw a box that the octogon should fit within
TBRIK *mybrik = new TBRIK("box","box","void",size,size,size);
TNode *mybriknode = new TNode("box","box","box");
cout << "draw brick of size dx = dy = " << size << endl;

// For GEANT3 PGON
//      RMIN/MAX: radius of the circle tangent to the sides of the
//                inner/outer polygon in the cross-section
//
// ... so this means that "r" is the _incribed_ circle radius
//     (tangent to the sides).

// draw an octogon with no scaling ... DOESN'T FIT!
TPGON *oct1 = new TPGON("oct1","oct1","void",-22.5,360.,8,2);
rout = size;
zmin = -size;
zmax = zmin + .1*size;
oct1->DefineSection(0,zmin,rin,rout);
oct1->DefineSection(1,zmax,rin,rout);
TNode *oct1node = new TNode("oct1","oct1","oct1");
oct1node->SetLineColor(2);
cout <<  "draw a red octogon with outer radius = " 
<< rout << " (no scaling) " << endl;

Float_t deg2rad  = TMath::Pi()/180;
Float_t cos22p5  = TMath::Cos(deg2rad*45/2);
Float_t sin45    = TMath::Sin(deg2rad*45);
 
// draw an octogon with a scaled radius
// take out the incorrect factor, put in the correct factor
TPGON *oct2 = new TPGON("oct2","oct2","void",-22.5,360.,8,2);
rout = size * sin45 / cos22p5;
zmax = size;
zmin = zmax - .1*size;
oct2->DefineSection(0,zmin,rin,rout);
oct2->DefineSection(1,zmax,rin,rout);
TNode *oct2node = new TNode("oct2","oct2","oct2");
oct2node->SetLineColor(3);
cout <<  "draw a green octogon with outer radius = " 
<< rout << " (to correct scaling) " <<  endl;

TCanvas *c1 = new TCanvas("c1","test octogon size",200,10,700,700);
testgeom->Draw();
}



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:22 MET