Files
geant4/source/geometry/solids/CSG/include/G4Sphere.icc
T
2016-06-09 14:55:03 +02:00

221 lines
5.1 KiB
Plaintext

//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4Sphere.icc,v 1.7 2006/10/19 15:33:37 gcosmo Exp $
// GEANT4 tag $Name: geant4-08-02 $
//
// --------------------------------------------------------------------
// GEANT 4 inline definitions file
//
// G4Sphere.icc
//
// Implementation of inline methods of G4Sphere
// --------------------------------------------------------------------
inline
G4double G4Sphere::GetInsideRadius() const
{
return fRmin;
}
inline
G4double G4Sphere::GetOuterRadius() const
{
return fRmax;
}
inline
G4double G4Sphere::GetStartPhiAngle() const
{
return fSPhi;
}
inline
G4double G4Sphere::GetDeltaPhiAngle() const
{
return fDPhi;
}
inline
G4double G4Sphere::GetStartThetaAngle() const
{
return fSTheta;
}
G4double G4Sphere::GetDeltaThetaAngle() const
{
return fDTheta;
}
inline
void G4Sphere::SetInsideRadius(G4double newRmin)
{
fRmin= newRmin;
fCubicVolume= 0.;
fSurfaceArea= 0.;
fpPolyhedron = 0;
}
inline
void G4Sphere::SetOuterRadius(G4double newRmax)
{
fRmax= newRmax;
fCubicVolume= 0.;
fSurfaceArea= 0.;
fpPolyhedron = 0;
}
inline
void G4Sphere::SetStartPhiAngle(G4double newSphi)
{
fSPhi= newSphi;
fCubicVolume= 0.;
fSurfaceArea= 0.;
fpPolyhedron = 0;
}
inline
void G4Sphere::SetDeltaPhiAngle(G4double newDphi)
{
fDPhi= newDphi;
fCubicVolume= 0.;
fSurfaceArea= 0.;
fpPolyhedron = 0;
}
inline
void G4Sphere::SetStartThetaAngle(G4double newSTheta)
{
fSTheta=newSTheta;
fCubicVolume= 0.;
fSurfaceArea= 0.;
fpPolyhedron = 0;
}
inline
void G4Sphere::SetDeltaThetaAngle(G4double newDTheta)
{
fDTheta=newDTheta;
fCubicVolume= 0.;
fSurfaceArea= 0.;
fpPolyhedron = 0;
}
// Old access functions
inline
G4double G4Sphere::GetRmin() const
{
return GetInsideRadius();
}
inline
G4double G4Sphere::GetRmax() const
{
return GetOuterRadius();
}
inline
G4double G4Sphere::GetSPhi() const
{
return GetStartPhiAngle();
}
inline
G4double G4Sphere::GetDPhi() const
{
return GetDeltaPhiAngle();
}
inline
G4double G4Sphere::GetSTheta() const
{
return GetStartThetaAngle();
}
inline
G4double G4Sphere::GetDTheta() const
{
return GetDeltaThetaAngle();
}
inline
G4double G4Sphere::GetCubicVolume()
{
if(fCubicVolume != 0.) {;}
else fCubicVolume = fDPhi*(std::cos(fSTheta)-std::cos(fSTheta+fDTheta))*
(fRmax*fRmax*fRmax-fRmin*fRmin*fRmin)/3.;
return fCubicVolume;
}
inline
G4double G4Sphere::GetSurfaceArea()
{
if(fSurfaceArea != 0.) {;}
else
{
G4double Rsq=fRmax*fRmax;
G4double rsq=fRmin*fRmin;
fSurfaceArea = fDPhi*(rsq+Rsq)*(std::cos(fSTheta)
- std::cos(fSTheta+fDTheta));
if(fDPhi < twopi)
{
fSurfaceArea = fSurfaceArea + fDTheta*(Rsq-rsq);
}
if(fSTheta >0)
{
G4double acos1=std::acos( std::pow(std::sin(fSTheta),2)
*std::cos(fDPhi)
+std::pow(std::cos(fSTheta),2));
if(fDPhi>pi)
{
fSurfaceArea = fSurfaceArea + 0.5*(Rsq-rsq)*(twopi-acos1);
}
else
{
fSurfaceArea = fSurfaceArea + 0.5*(Rsq-rsq)*acos1;
}
}
if(fDTheta+fSTheta < pi)
{
G4double acos2=std::acos( std::pow(std::sin(fSTheta+fDTheta),2)
*std::cos(fDPhi)
+std::pow(std::cos(fSTheta+fDTheta),2));
if(fDPhi>pi)
{
fSurfaceArea = fSurfaceArea + 0.5*(Rsq-rsq)*(twopi-acos2);
}
else
{
fSurfaceArea = fSurfaceArea + 0.5*(Rsq-rsq)*acos2;
}
}
}
return fSurfaceArea;
}