TGTRA.cxx

Go to the documentation of this file.
00001 // @(#)root/g3d:$Id: TGTRA.cxx 31624 2009-12-08 09:58:40Z couet $
00002 // Author: Nenad Buncic   19/09/95
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #include "TGTRA.h"
00013 #include "TNode.h"
00014 #include "TMath.h"
00015 
00016 ClassImp(TGTRA)
00017 
00018 
00019 //______________________________________________________________________________
00020 // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/gtra.gif"> </P> End_Html
00021 // GTRA is a general twisted trapezoid. The faces perpendicular to z are trapezia
00022 // and their centres are not necessarily on a line parallel to the z axis as the
00023 // TRAP; additionally, the faces may be twisted so that none of their edges are
00024 // parallel. It is a TRAP shape, except that it is twisted in the x-y plane as a
00025 // function of z. The parallel sides perpendicular to the z axis are rotated with
00026 // respect to the x axis by an angle TWIST, which is one of the parameters. The
00027 // shape is defined by the eight corners and is assumed to be constructed of
00028 // straight lines joining points on the boundary of the trapezoidal face at z=-DZ
00029 // to the corresponding points on the face at z=DZ. Divisions are not allowed.
00030 // It has 15 parameters:
00031 //
00032 //     - name       name of the shape
00033 //     - title      shape's title
00034 //     - material  (see TMaterial)
00035 //     - dZ         half-length along the z axis
00036 //     - theta      polar angle of the line joining the centre of the face
00037 //                  at -DZ to the centre of the one at +DZ
00038 //     - phi        azimuthal angle of the line joining the centre of
00039 //                  the face at -DZ to the centre of the one at +DZ
00040 //     - twist      twist angle of the faces parallel to the x-y plane
00041 //                  at z = +/- DZ around an axis parallel to z passing
00042 //                  through their centre
00043 //     - h1         half-length along y of the face at -DZ
00044 //     - bl1        half-length along x of the side at -H1 in y of
00045 //                  the face at -DZ in z
00046 //     - tl1        half-length along x of the side at +H1 in y of the face
00047 //                  at -DZ in z
00048 //     - alpha1     angle with respect to the y axis from the centre of
00049 //                  the side at -H1 in y to the centre of the side at
00050 //                  +H1 in y of the face at -DZ in z
00051 //     - h2         half-length along y of the face at +DZ
00052 //     - bL2        half-length along x of the side at -H2 in y of the face at
00053 //                  +DZ in z
00054 //
00055 //     - tl2        half-length along x of the side at +H2 in y of the face
00056 //                  at +DZ in z
00057 //
00058 //     - alpha2     angle with respect to the y axis from the centre of the side
00059 //                  at -H2 in y to the centre of the side at +H2 in y of the
00060 //                  face at +DZ in z
00061 
00062 
00063 
00064 
00065 
00066 //______________________________________________________________________________
00067 TGTRA::TGTRA ()
00068 {
00069    // GTRA shape default constructor.
00070 
00071    fTwist  = 0.;
00072    fH1     = 0.;
00073    fBl1    = 0.;
00074    fTl1    = 0.;
00075    fAlpha1 = 0.;
00076    fH2     = 0.;
00077    fBl2    = 0.;
00078    fTl2    = 0.;
00079    fAlpha2 = 0.;
00080 }
00081 
00082 
00083 //______________________________________________________________________________
00084 TGTRA::TGTRA (const char *name, const char *title, const char *material, Float_t dz, Float_t theta,
00085               Float_t phi, Float_t twist, Float_t h1, Float_t bl1, Float_t tl1, Float_t alpha1,
00086               Float_t h2, Float_t bl2, Float_t tl2, Float_t alpha2)
00087       : TBRIK (name, title, material, theta, phi, dz)
00088 {
00089    // GTRA shape normal constructor
00090 
00091    fTwist  = twist;
00092    fH1     = h1;
00093    fBl1    = bl1;
00094    fTl1    = tl1;
00095    fAlpha1 = alpha1;
00096    fH2     = h2;
00097    fBl2    = bl2;
00098    fTl2    = tl2;
00099    fAlpha2 = alpha2;
00100 }
00101 
00102 
00103 //______________________________________________________________________________
00104 TGTRA::~TGTRA ()
00105 {
00106    // GTRA shape default destructor
00107 }
00108 
00109 //______________________________________________________________________________
00110 void TGTRA::SetPoints (Double_t *points) const
00111 {
00112    // Create GTRA points
00113 
00114    Double_t x, y, dx, dy, dx1, dx2, dz, theta, phi, alpha1, alpha2, twist;
00115    const Float_t pi = Float_t (TMath::Pi());
00116 
00117    alpha1 = fAlpha1    * pi/180.0;
00118    alpha2 = fAlpha2    * pi/180.0;
00119    theta  = TBRIK::fDx * pi/180.0;
00120    phi    = TBRIK::fDy * pi/180.0;
00121    twist  = fTwist     * pi/180.0;
00122 
00123    dx  = 2*fDz*TMath::Sin(theta)*TMath::Cos(phi);
00124    dy  = 2*fDz*TMath::Sin(theta)*TMath::Sin(phi);
00125    dz  = TBRIK::fDz;
00126 
00127    dx1 = 2*fH1*TMath::Tan(alpha1);
00128    dx2 = 2*fH2*TMath::Tan(alpha2);
00129 
00130    if (points) {
00131       points[ 0] = -fBl1;        points[ 1] = -fH1;    points[ 2] = -dz;
00132       points[ 9] =  fBl1;        points[10] = -fH1;    points[11] = -dz;
00133       points[ 6] =  fTl1+dx1;    points[ 7] =  fH1;    points[ 8] = -dz;
00134       points[ 3] = -fTl1+dx1;    points[4]  =  fH1;    points[5] = -dz;
00135       points[12] = -fBl2+dx;     points[13] = -fH2+dy; points[14] = dz;
00136       points[21] =  fBl2+dx;     points[22] = -fH2+dy; points[23] = dz;
00137       points[18] =  fTl2+dx+dx2; points[19] =  fH2+dy; points[20] = dz;
00138       points[15] = -fTl2+dx+dx2; points[16] =  fH2+dy; points[17] = dz;
00139       for (Int_t i = 12; i < 24; i+=3) {
00140          x = points[i];
00141          y = points[i+1];
00142          points[i]     = x*TMath::Cos(twist) + y*TMath::Sin(twist);
00143          points[i+1]  = -x*TMath::Sin(twist) + y*TMath::Cos(twist);
00144       }
00145    }
00146 }

Generated on Tue Jul 5 14:16:40 2011 for ROOT_528-00b_version by  doxygen 1.5.1