Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGTRA.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 "TGTRA.h"
13#include "TNode.h"
14#include "TMath.h"
15
17
18/** \class TGTRA
19\ingroup g3d
20A general twisted trapezoid.
21
22\image html g3d_gtra.png
23
24The faces perpendicular to z are trapezia
25and their centres are not necessarily on a line parallel to the z axis as the
26TRAP; additionally, the faces may be twisted so that none of their edges are
27parallel. It is a TRAP shape, except that it is twisted in the x-y plane as a
28function of z. The parallel sides perpendicular to the z axis are rotated with
29respect to the x axis by an angle TWIST, which is one of the parameters. The
30shape is defined by the eight corners and is assumed to be constructed of
31straight lines joining points on the boundary of the trapezoidal face at z=-DZ
32to the corresponding points on the face at z=DZ. Divisions are not allowed.
33It has 15 parameters:
34
35 - name: name of the shape
36 - title: shape's title
37 - material: (see TMaterial)
38 - dZ: half-length along the z axis
39 - theta: polar angle of the line joining the centre of the face
40 at -DZ to the centre of the one at +DZ
41 - phi: azimuthal angle of the line joining the centre of
42 the face at -DZ to the centre of the one at +DZ
43 - twist: twist angle of the faces parallel to the x-y plane
44 at z = +/- DZ around an axis parallel to z passing
45 through their centre
46 - h1: half-length along y of the face at -DZ
47 - bl1: half-length along x of the side at -H1 in y of
48 the face at -DZ in z
49 - tl1: half-length along x of the side at +H1 in y of the face
50 at -DZ in z
51 - alpha1: angle with respect to the y axis from the centre of
52 the side at -H1 in y to the centre of the side at
53 +H1 in y of the face at -DZ in z
54 - h2: half-length along y of the face at +DZ
55 - bL2: half-length along x of the side at -H2 in y of the face at
56 +DZ in z
57 - tl2: half-length along x of the side at +H2 in y of the face
58 at +DZ in z
59 - alpha2: angle with respect to the y axis from the centre of the side
60 at -H2 in y to the centre of the side at +H2 in y of the
61 face at +DZ in z
62*/
63
64////////////////////////////////////////////////////////////////////////////////
65/// GTRA shape default constructor.
66
68{
69 fTwist = 0.;
70 fH1 = 0.;
71 fBl1 = 0.;
72 fTl1 = 0.;
73 fAlpha1 = 0.;
74 fH2 = 0.;
75 fBl2 = 0.;
76 fTl2 = 0.;
77 fAlpha2 = 0.;
78}
79
80////////////////////////////////////////////////////////////////////////////////
81/// GTRA shape normal constructor
82
83TGTRA::TGTRA (const char *name, const char *title, const char *material, Float_t dz, Float_t theta,
84 Float_t phi, Float_t twist, Float_t h1, Float_t bl1, Float_t tl1, Float_t alpha1,
85 Float_t h2, Float_t bl2, Float_t tl2, Float_t alpha2)
86 : TBRIK (name, title, material, theta, phi, dz)
87{
88 fTwist = twist;
89 fH1 = h1;
90 fBl1 = bl1;
91 fTl1 = tl1;
92 fAlpha1 = alpha1;
93 fH2 = h2;
94 fBl2 = bl2;
95 fTl2 = tl2;
96 fAlpha2 = alpha2;
97}
98
99////////////////////////////////////////////////////////////////////////////////
100/// GTRA shape default destructor
101
103{
104}
105
106////////////////////////////////////////////////////////////////////////////////
107/// Create GTRA points
108
110{
111 Double_t x, y, dx, dy, dx1, dx2, dz, theta, phi, alpha1, alpha2, twist;
112 const Float_t pi = Float_t (TMath::Pi());
113
114 alpha1 = fAlpha1 * pi/180.0;
115 alpha2 = fAlpha2 * pi/180.0;
116 theta = TBRIK::fDx * pi/180.0;
117 phi = TBRIK::fDy * pi/180.0;
118 twist = fTwist * pi/180.0;
119
120 dx = 2*fDz*TMath::Sin(theta)*TMath::Cos(phi);
121 dy = 2*fDz*TMath::Sin(theta)*TMath::Sin(phi);
122 dz = TBRIK::fDz;
123
124 dx1 = 2*fH1*TMath::Tan(alpha1);
125 dx2 = 2*fH2*TMath::Tan(alpha2);
126
127 if (points) {
128 points[ 0] = -fBl1; points[ 1] = -fH1; points[ 2] = -dz;
129 points[ 9] = fBl1; points[10] = -fH1; points[11] = -dz;
130 points[ 6] = fTl1+dx1; points[ 7] = fH1; points[ 8] = -dz;
131 points[ 3] = -fTl1+dx1; points[4] = fH1; points[5] = -dz;
132 points[12] = -fBl2+dx; points[13] = -fH2+dy; points[14] = dz;
133 points[21] = fBl2+dx; points[22] = -fH2+dy; points[23] = dz;
134 points[18] = fTl2+dx+dx2; points[19] = fH2+dy; points[20] = dz;
135 points[15] = -fTl2+dx+dx2; points[16] = fH2+dy; points[17] = dz;
136 for (Int_t i = 12; i < 24; i+=3) {
137 x = points[i];
138 y = points[i+1];
139 points[i] = x*TMath::Cos(twist) + y*TMath::Sin(twist);
140 points[i+1] = -x*TMath::Sin(twist) + y*TMath::Cos(twist);
141 }
142 }
143}
double Double_t
Definition RtypesCore.h:59
float Float_t
Definition RtypesCore.h:57
#define ClassImp(name)
Definition Rtypes.h:364
char name[80]
Definition TGX11.cxx:110
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 twisted trapezoid.
Definition TGTRA.h:27
virtual void SetPoints(Double_t *points) const
Create GTRA points.
Definition TGTRA.cxx:109
Float_t fH1
Definition TGTRA.h:31
Float_t fBl1
Definition TGTRA.h:32
Float_t fTwist
Definition TGTRA.h:30
virtual ~TGTRA()
GTRA shape default destructor.
Definition TGTRA.cxx:102
Float_t fAlpha2
Definition TGTRA.h:38
Float_t fAlpha1
Definition TGTRA.h:34
Float_t fBl2
Definition TGTRA.h:36
Float_t fH2
Definition TGTRA.h:35
TGTRA()
GTRA shape default constructor.
Definition TGTRA.cxx:67
Float_t fTl1
Definition TGTRA.h:33
Float_t fTl2
Definition TGTRA.h:37
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
TH1F * h1
Definition legend1.C:5
Double_t Cos(Double_t)
Definition TMath.h:643
constexpr Double_t Pi()
Definition TMath.h:37
Double_t Sin(Double_t)
Definition TMath.h:639
Double_t Tan(Double_t)
Definition TMath.h:647