Logo ROOT   6.18/05
Reference Guide
TTRAP.cxx
Go to the documentation of this file.
1// @(#)root/g3d:$Id$
2// Author: Nenad Buncic 19/09/95
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include "TTRAP.h"
13#include "TNode.h"
14#include "TMath.h"
15
17
18/** \class TTRAP
19\ingroup g3d
20A general trapezoid.
21
22\image html g3d_trap.png
23
24The faces perpendicular to z are trapezia and
25their centres are not necessarily on a line parallel to the z axis.
26This shape has 14 parameters.
27
28 - name: name of the shape
29 - title: shape's title
30 - material: (see TMaterial)
31 - dz: half-length along the z axis
32 - theta: polar angle of the line joining the centre of the face
33 at -DZ to the centre of the one at +DZ
34 - phi: azimuthal angle of the line joining the centre of the face
35 at -DZ to the centre of the one at +DZ
36 - h1: half-length along y of the face at -DZ
37 - bl1: half-length along x of the side at -H1 in y of the face
38 at -DZ in z
39 - tl1: half-length along x of the side at +H1 in y of the face
40 at -DZ in z
41 - alpha1: angle with respect to the y axis from the centre of the
42 side at -H1 in y to the centre of the side at +H1 in y
43 of the face at -DZ in z
44 - h2: half-length along y of the face at +DZ
45 - bl2: half-length along x of the side at -H2 in y of the
46 face at +DZ in z
47 - tl2: half-length along x of the side at +H2 in y of the face
48 at +DZ in z
49 - alpha2: angle with respect to the y axis from the centre of the side
50 at -H2 in y to the centre of the side at +H2 in y of the
51 face at +DZ in z
52*/
53
54////////////////////////////////////////////////////////////////////////////////
55/// TRAP shape default constructor
56
58{
59 fH1 = 0.;
60 fBl1 = 0.;
61 fTl1 = 0.;
62 fAlpha1 = 0.;
63 fH2 = 0.;
64 fBl2 = 0.;
65 fTl2 = 0.;
66 fAlpha2 = 0.;
67}
68
69////////////////////////////////////////////////////////////////////////////////
70/// TRAP shape normal constructor
71
72TTRAP::TTRAP(const char *name, const char *title, const char *material, Float_t dz, Float_t theta, Float_t phi,
73 Float_t h1, Float_t bl1, Float_t tl1, Float_t alpha1, Float_t h2,
74 Float_t bl2, Float_t tl2, Float_t alpha2) : TBRIK(name, title,material,theta,phi,dz)
75{
76 fH1 = h1;
77 fBl1 = bl1;
78 fTl1 = tl1;
79 fAlpha1 = alpha1;
80 fH2 = h2;
81 fBl2 = bl2;
82 fTl2 = tl2;
83 fAlpha2 = alpha2;
84}
85
86////////////////////////////////////////////////////////////////////////////////
87/// TRAP shape default destructor
88
90{
91}
92
93////////////////////////////////////////////////////////////////////////////////
94/// Create TRAP points
95
97{
98 const Float_t pi = Float_t (TMath::Pi());
99 Float_t alpha1 = fAlpha1 * pi/180.0;
100 Float_t alpha2 = fAlpha2 * pi/180.0;
101 Float_t theta = TBRIK::fDx * pi/180.0;
102 Float_t phi = TBRIK::fDy * pi/180.0;
103 Float_t tth = TMath::Tan(theta);
104 Float_t tx = tth*TMath::Cos(phi);
105 Float_t ty = tth*TMath::Sin(phi);
106 Float_t tth1 = TMath::Tan(alpha1);
107 Float_t tth2 = TMath::Tan(alpha2);
108
109 if (points) {
110 points[ 0] = -fDz*tx-tth1*fH1-fBl1 ; points[ 1] = -fH1-fDz*ty ; points[ 2] = -fDz;
111 points[ 3] = -fDz*tx+tth1*fH1-fTl1 ; points[ 4] = fH1-fDz*ty ; points[ 5] = -fDz;
112 points[ 6] = -fDz*tx+tth1*fH1+fTl1 ; points[ 7] = fH1-fDz*ty ; points[ 8] = -fDz;
113 points[ 9] = -fDz*tx-tth1*fH1+fBl1 ; points[10] = -fH1-fDz*ty ; points[11] = -fDz;
114 points[12] = fDz*tx-tth2*fH2-fBl2 ; points[13] = -fH2+fDz*ty ; points[14] = fDz;
115 points[15] = fDz*tx+tth2*fH2-fTl2 ; points[16] = fH2+fDz*ty ; points[17] = fDz;
116 points[18] = fDz*tx+tth2*fH2+fTl2 ; points[19] = fH2+fDz*ty ; points[20] = fDz;
117 points[21] = fDz*tx-tth2*fH2+fBl2 ; points[22] = -fH2+fDz*ty ; points[23] = fDz;
118 }
119
120}
double Double_t
Definition: RtypesCore.h:55
float Float_t
Definition: RtypesCore.h:53
#define ClassImp(name)
Definition: Rtypes.h:365
char name[80]
Definition: TGX11.cxx:109
point * points
Definition: X3DBuffer.c:22
A box with faces perpendicular to the axes.
Definition: TBRIK.h:26
Float_t fDz
Definition: TBRIK.h:31
Float_t fDy
Definition: TBRIK.h:30
Float_t fDx
Definition: TBRIK.h:29
A general trapezoid.
Definition: TTRAP.h:33
Float_t fAlpha1
Definition: TTRAP.h:38
Float_t fAlpha2
Definition: TTRAP.h:42
virtual ~TTRAP()
TRAP shape default destructor.
Definition: TTRAP.cxx:89
Float_t fH1
Definition: TTRAP.h:35
Float_t fTl1
Definition: TTRAP.h:37
TTRAP()
TRAP shape default constructor.
Definition: TTRAP.cxx:57
Float_t fBl2
Definition: TTRAP.h:40
Float_t fH2
Definition: TTRAP.h:39
Float_t fBl1
Definition: TTRAP.h:36
Float_t fTl2
Definition: TTRAP.h:41
virtual void SetPoints(Double_t *points) const
Create TRAP points.
Definition: TTRAP.cxx:96
TH1F * h1
Definition: legend1.C:5
static constexpr double pi
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
Double_t Tan(Double_t)
Definition: TMath.h:633