1 | // |
---|
2 | // ******************************************************************** |
---|
3 | // * License and Disclaimer * |
---|
4 | // * * |
---|
5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
7 | // * conditions of the Geant4 Software License, included in the file * |
---|
8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
9 | // * include a list of copyright holders. * |
---|
10 | // * * |
---|
11 | // * Neither the authors of this software system, nor their employing * |
---|
12 | // * institutes,nor the agencies providing financial support for this * |
---|
13 | // * work make any representation or warranty, express or implied, * |
---|
14 | // * regarding this software system or assume any liability for its * |
---|
15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
16 | // * for the full disclaimer and the limitation of liability. * |
---|
17 | // * * |
---|
18 | // * This code implementation is the result of the scientific and * |
---|
19 | // * technical work of the GEANT4 collaboration. * |
---|
20 | // * By using, copying, modifying or distributing the software (or * |
---|
21 | // * any work based on the software) you agree to acknowledge its * |
---|
22 | // * use in resulting scientific publications, and indicate your * |
---|
23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
24 | // ******************************************************************** |
---|
25 | // |
---|
26 | // |
---|
27 | // $Id: G4Sphere.icc,v 1.8 2008/11/21 09:50:05 gcosmo Exp $ |
---|
28 | // GEANT4 tag $Name: geant4-09-02-cand-01 $ |
---|
29 | // |
---|
30 | // -------------------------------------------------------------------- |
---|
31 | // GEANT 4 inline definitions file |
---|
32 | // |
---|
33 | // G4Sphere.icc |
---|
34 | // |
---|
35 | // Implementation of inline methods of G4Sphere |
---|
36 | // -------------------------------------------------------------------- |
---|
37 | |
---|
38 | inline |
---|
39 | G4double G4Sphere::GetInsideRadius() const |
---|
40 | { |
---|
41 | return fRmin; |
---|
42 | } |
---|
43 | |
---|
44 | inline |
---|
45 | G4double G4Sphere::GetInnerRadius() const |
---|
46 | { |
---|
47 | return fRmin; |
---|
48 | } |
---|
49 | |
---|
50 | inline |
---|
51 | G4double G4Sphere::GetOuterRadius() const |
---|
52 | { |
---|
53 | return fRmax; |
---|
54 | } |
---|
55 | |
---|
56 | inline |
---|
57 | G4double G4Sphere::GetStartPhiAngle() const |
---|
58 | { |
---|
59 | return fSPhi; |
---|
60 | } |
---|
61 | |
---|
62 | inline |
---|
63 | G4double G4Sphere::GetDeltaPhiAngle() const |
---|
64 | { |
---|
65 | return fDPhi; |
---|
66 | } |
---|
67 | |
---|
68 | inline |
---|
69 | G4double G4Sphere::GetStartThetaAngle() const |
---|
70 | { |
---|
71 | return fSTheta; |
---|
72 | } |
---|
73 | |
---|
74 | G4double G4Sphere::GetDeltaThetaAngle() const |
---|
75 | { |
---|
76 | return fDTheta; |
---|
77 | } |
---|
78 | |
---|
79 | inline |
---|
80 | void G4Sphere::SetInsideRadius(G4double newRmin) |
---|
81 | { |
---|
82 | fRmin= newRmin; |
---|
83 | fCubicVolume= 0.; |
---|
84 | fSurfaceArea= 0.; |
---|
85 | fpPolyhedron = 0; |
---|
86 | } |
---|
87 | |
---|
88 | inline |
---|
89 | void G4Sphere::SetInnerRadius(G4double newRmin) |
---|
90 | { |
---|
91 | fRmin= newRmin; |
---|
92 | fCubicVolume= 0.; |
---|
93 | fSurfaceArea= 0.; |
---|
94 | fpPolyhedron = 0; |
---|
95 | } |
---|
96 | |
---|
97 | inline |
---|
98 | void G4Sphere::SetOuterRadius(G4double newRmax) |
---|
99 | { |
---|
100 | fRmax= newRmax; |
---|
101 | fCubicVolume= 0.; |
---|
102 | fSurfaceArea= 0.; |
---|
103 | fpPolyhedron = 0; |
---|
104 | } |
---|
105 | |
---|
106 | inline |
---|
107 | void G4Sphere::SetStartPhiAngle(G4double newSphi) |
---|
108 | { |
---|
109 | fSPhi= newSphi; |
---|
110 | fCubicVolume= 0.; |
---|
111 | fSurfaceArea= 0.; |
---|
112 | fpPolyhedron = 0; |
---|
113 | } |
---|
114 | |
---|
115 | inline |
---|
116 | void G4Sphere::SetDeltaPhiAngle(G4double newDphi) |
---|
117 | { |
---|
118 | fDPhi= newDphi; |
---|
119 | fCubicVolume= 0.; |
---|
120 | fSurfaceArea= 0.; |
---|
121 | fpPolyhedron = 0; |
---|
122 | } |
---|
123 | |
---|
124 | inline |
---|
125 | void G4Sphere::SetStartThetaAngle(G4double newSTheta) |
---|
126 | { |
---|
127 | fSTheta=newSTheta; |
---|
128 | fCubicVolume= 0.; |
---|
129 | fSurfaceArea= 0.; |
---|
130 | fpPolyhedron = 0; |
---|
131 | } |
---|
132 | |
---|
133 | inline |
---|
134 | void G4Sphere::SetDeltaThetaAngle(G4double newDTheta) |
---|
135 | { |
---|
136 | fDTheta=newDTheta; |
---|
137 | fCubicVolume= 0.; |
---|
138 | fSurfaceArea= 0.; |
---|
139 | fpPolyhedron = 0; |
---|
140 | } |
---|
141 | |
---|
142 | // Old access functions |
---|
143 | |
---|
144 | inline |
---|
145 | G4double G4Sphere::GetRmin() const |
---|
146 | { |
---|
147 | return GetInsideRadius(); |
---|
148 | } |
---|
149 | |
---|
150 | inline |
---|
151 | G4double G4Sphere::GetRmax() const |
---|
152 | { |
---|
153 | return GetOuterRadius(); |
---|
154 | } |
---|
155 | |
---|
156 | inline |
---|
157 | G4double G4Sphere::GetSPhi() const |
---|
158 | { |
---|
159 | return GetStartPhiAngle(); |
---|
160 | } |
---|
161 | |
---|
162 | inline |
---|
163 | G4double G4Sphere::GetDPhi() const |
---|
164 | { |
---|
165 | return GetDeltaPhiAngle(); |
---|
166 | } |
---|
167 | |
---|
168 | inline |
---|
169 | G4double G4Sphere::GetSTheta() const |
---|
170 | { |
---|
171 | return GetStartThetaAngle(); |
---|
172 | } |
---|
173 | |
---|
174 | inline |
---|
175 | G4double G4Sphere::GetDTheta() const |
---|
176 | { |
---|
177 | return GetDeltaThetaAngle(); |
---|
178 | } |
---|
179 | |
---|
180 | inline |
---|
181 | G4double G4Sphere::GetCubicVolume() |
---|
182 | { |
---|
183 | if(fCubicVolume != 0.) {;} |
---|
184 | else fCubicVolume = fDPhi*(std::cos(fSTheta)-std::cos(fSTheta+fDTheta))* |
---|
185 | (fRmax*fRmax*fRmax-fRmin*fRmin*fRmin)/3.; |
---|
186 | return fCubicVolume; |
---|
187 | } |
---|
188 | |
---|
189 | |
---|
190 | inline |
---|
191 | G4double G4Sphere::GetSurfaceArea() |
---|
192 | { |
---|
193 | if(fSurfaceArea != 0.) {;} |
---|
194 | else |
---|
195 | { |
---|
196 | G4double Rsq=fRmax*fRmax; |
---|
197 | G4double rsq=fRmin*fRmin; |
---|
198 | |
---|
199 | fSurfaceArea = fDPhi*(rsq+Rsq)*(std::cos(fSTheta) |
---|
200 | - std::cos(fSTheta+fDTheta)); |
---|
201 | if(fDPhi < twopi) |
---|
202 | { |
---|
203 | fSurfaceArea = fSurfaceArea + fDTheta*(Rsq-rsq); |
---|
204 | } |
---|
205 | if(fSTheta >0) |
---|
206 | { |
---|
207 | G4double acos1=std::acos( std::pow(std::sin(fSTheta),2) |
---|
208 | *std::cos(fDPhi) |
---|
209 | +std::pow(std::cos(fSTheta),2)); |
---|
210 | if(fDPhi>pi) |
---|
211 | { |
---|
212 | fSurfaceArea = fSurfaceArea + 0.5*(Rsq-rsq)*(twopi-acos1); |
---|
213 | } |
---|
214 | else |
---|
215 | { |
---|
216 | fSurfaceArea = fSurfaceArea + 0.5*(Rsq-rsq)*acos1; |
---|
217 | } |
---|
218 | } |
---|
219 | if(fDTheta+fSTheta < pi) |
---|
220 | { |
---|
221 | G4double acos2=std::acos( std::pow(std::sin(fSTheta+fDTheta),2) |
---|
222 | *std::cos(fDPhi) |
---|
223 | +std::pow(std::cos(fSTheta+fDTheta),2)); |
---|
224 | if(fDPhi>pi) |
---|
225 | { |
---|
226 | fSurfaceArea = fSurfaceArea + 0.5*(Rsq-rsq)*(twopi-acos2); |
---|
227 | } |
---|
228 | else |
---|
229 | { |
---|
230 | fSurfaceArea = fSurfaceArea + 0.5*(Rsq-rsq)*acos2; |
---|
231 | } |
---|
232 | } |
---|
233 | } |
---|
234 | return fSurfaceArea; |
---|
235 | } |
---|