source: trunk/source/geometry/solids/CSG/include/G4Sphere.icc @ 1202

Last change on this file since 1202 was 1058, checked in by garnier, 15 years ago

file release beta

File size: 5.3 KB
Line 
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-ref-02 $
29//
30// --------------------------------------------------------------------
31// GEANT 4 inline definitions file
32//
33// G4Sphere.icc
34//
35// Implementation of inline methods of G4Sphere
36// --------------------------------------------------------------------
37
38inline
39G4double G4Sphere::GetInsideRadius() const
40{
41  return fRmin;
42}
43
44inline
45G4double G4Sphere::GetInnerRadius() const
46{
47  return fRmin;
48}
49
50inline
51G4double G4Sphere::GetOuterRadius() const
52{
53  return fRmax;
54}
55
56inline
57G4double G4Sphere::GetStartPhiAngle() const
58{
59  return fSPhi;
60}
61
62inline
63G4double G4Sphere::GetDeltaPhiAngle() const
64{
65  return fDPhi;
66}
67
68inline
69G4double G4Sphere::GetStartThetaAngle() const
70{
71  return fSTheta;
72}
73
74G4double G4Sphere::GetDeltaThetaAngle() const
75{
76  return fDTheta;
77}
78
79inline
80void G4Sphere::SetInsideRadius(G4double newRmin)
81{
82  fRmin= newRmin;
83  fCubicVolume= 0.;
84  fSurfaceArea= 0.;
85  fpPolyhedron = 0;
86}
87
88inline
89void G4Sphere::SetInnerRadius(G4double newRmin)
90{
91  fRmin= newRmin;
92  fCubicVolume= 0.;
93  fSurfaceArea= 0.;
94  fpPolyhedron = 0;
95}
96
97inline
98void G4Sphere::SetOuterRadius(G4double newRmax)
99{
100  fRmax= newRmax;
101  fCubicVolume= 0.;
102  fSurfaceArea= 0.;
103  fpPolyhedron = 0;
104}
105
106inline
107void G4Sphere::SetStartPhiAngle(G4double newSphi)
108{
109  fSPhi= newSphi;
110  fCubicVolume= 0.;
111  fSurfaceArea= 0.;
112  fpPolyhedron = 0;
113}
114
115inline
116void G4Sphere::SetDeltaPhiAngle(G4double newDphi)
117{
118  fDPhi= newDphi;
119  fCubicVolume= 0.;
120  fSurfaceArea= 0.;
121  fpPolyhedron = 0;
122}
123
124inline
125void G4Sphere::SetStartThetaAngle(G4double newSTheta)
126{
127  fSTheta=newSTheta;
128  fCubicVolume= 0.;
129  fSurfaceArea= 0.;
130  fpPolyhedron = 0;
131}
132
133inline
134void G4Sphere::SetDeltaThetaAngle(G4double newDTheta)
135{
136  fDTheta=newDTheta;
137  fCubicVolume= 0.;
138  fSurfaceArea= 0.;
139  fpPolyhedron = 0;
140}
141
142// Old access functions
143
144inline
145G4double G4Sphere::GetRmin() const
146{
147  return GetInsideRadius();
148}
149
150inline
151G4double G4Sphere::GetRmax() const
152{
153  return GetOuterRadius();
154}
155
156inline
157G4double G4Sphere::GetSPhi() const
158{
159  return GetStartPhiAngle();
160}
161
162inline
163G4double G4Sphere::GetDPhi() const
164{
165  return GetDeltaPhiAngle();
166}
167
168inline
169G4double G4Sphere::GetSTheta() const
170{
171  return GetStartThetaAngle();
172}
173
174inline
175G4double G4Sphere::GetDTheta() const
176{
177  return GetDeltaThetaAngle();
178}
179
180inline
181G4double 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
190inline
191G4double 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}
Note: See TracBrowser for help on using the repository browser.