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

Last change on this file since 836 was 831, checked in by garnier, 16 years ago

import all except CVS

File size: 5.1 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.7 2006/10/19 15:33:37 gcosmo Exp $
28// GEANT4 tag $Name:  $
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::GetOuterRadius() const
46{
47  return fRmax;
48}
49
50inline
51G4double G4Sphere::GetStartPhiAngle() const
52{
53  return fSPhi;
54}
55
56inline
57G4double G4Sphere::GetDeltaPhiAngle() const
58{
59  return fDPhi;
60}
61
62inline
63G4double G4Sphere::GetStartThetaAngle() const
64{
65  return fSTheta;
66}
67
68G4double G4Sphere::GetDeltaThetaAngle() const
69{
70  return fDTheta;
71}
72
73inline
74void G4Sphere::SetInsideRadius(G4double newRmin)
75{
76  fRmin= newRmin;
77  fCubicVolume= 0.;
78  fSurfaceArea= 0.;
79  fpPolyhedron = 0;
80}
81
82inline
83void G4Sphere::SetOuterRadius(G4double newRmax)
84{
85  fRmax= newRmax;
86  fCubicVolume= 0.;
87  fSurfaceArea= 0.;
88  fpPolyhedron = 0;
89}
90
91inline
92void G4Sphere::SetStartPhiAngle(G4double newSphi)
93{
94  fSPhi= newSphi;
95  fCubicVolume= 0.;
96  fSurfaceArea= 0.;
97  fpPolyhedron = 0;
98}
99
100inline
101void G4Sphere::SetDeltaPhiAngle(G4double newDphi)
102{
103  fDPhi= newDphi;
104  fCubicVolume= 0.;
105  fSurfaceArea= 0.;
106  fpPolyhedron = 0;
107}
108
109inline
110void G4Sphere::SetStartThetaAngle(G4double newSTheta)
111{
112  fSTheta=newSTheta;
113  fCubicVolume= 0.;
114  fSurfaceArea= 0.;
115  fpPolyhedron = 0;
116}
117
118inline
119void G4Sphere::SetDeltaThetaAngle(G4double newDTheta)
120{
121  fDTheta=newDTheta;
122  fCubicVolume= 0.;
123  fSurfaceArea= 0.;
124  fpPolyhedron = 0;
125}
126
127// Old access functions
128
129inline
130G4double G4Sphere::GetRmin() const
131{
132  return GetInsideRadius();
133}
134
135inline
136G4double G4Sphere::GetRmax() const
137{
138  return GetOuterRadius();
139}
140
141inline
142G4double G4Sphere::GetSPhi() const
143{
144  return GetStartPhiAngle();
145}
146
147inline
148G4double G4Sphere::GetDPhi() const
149{
150  return GetDeltaPhiAngle();
151}
152
153inline
154G4double G4Sphere::GetSTheta() const
155{
156  return GetStartThetaAngle();
157}
158
159inline
160G4double G4Sphere::GetDTheta() const
161{
162  return GetDeltaThetaAngle();
163}
164
165inline
166G4double G4Sphere::GetCubicVolume()
167{
168  if(fCubicVolume != 0.) {;}
169  else   fCubicVolume = fDPhi*(std::cos(fSTheta)-std::cos(fSTheta+fDTheta))*
170                              (fRmax*fRmax*fRmax-fRmin*fRmin*fRmin)/3.;
171  return fCubicVolume;
172}
173
174
175inline
176G4double G4Sphere::GetSurfaceArea()
177{
178  if(fSurfaceArea != 0.) {;}
179  else
180  {   
181    G4double Rsq=fRmax*fRmax;
182    G4double rsq=fRmin*fRmin;
183         
184    fSurfaceArea = fDPhi*(rsq+Rsq)*(std::cos(fSTheta)
185                 - std::cos(fSTheta+fDTheta));
186    if(fDPhi < twopi)
187    {
188      fSurfaceArea = fSurfaceArea + fDTheta*(Rsq-rsq);
189    }
190    if(fSTheta >0)
191    {
192      G4double acos1=std::acos( std::pow(std::sin(fSTheta),2)
193                               *std::cos(fDPhi)
194                               +std::pow(std::cos(fSTheta),2));
195      if(fDPhi>pi)
196      {
197        fSurfaceArea = fSurfaceArea + 0.5*(Rsq-rsq)*(twopi-acos1);
198      }
199      else
200      {
201        fSurfaceArea = fSurfaceArea + 0.5*(Rsq-rsq)*acos1;
202      }
203    }
204    if(fDTheta+fSTheta < pi)
205    {
206      G4double acos2=std::acos( std::pow(std::sin(fSTheta+fDTheta),2)
207                               *std::cos(fDPhi)
208                               +std::pow(std::cos(fSTheta+fDTheta),2));
209      if(fDPhi>pi)
210      {
211        fSurfaceArea = fSurfaceArea + 0.5*(Rsq-rsq)*(twopi-acos2);
212      }
213      else
214      {
215        fSurfaceArea = fSurfaceArea + 0.5*(Rsq-rsq)*acos2;
216      }
217    }
218  }
219  return fSurfaceArea;
220}
Note: See TracBrowser for help on using the repository browser.