59 USphere(
const std::string& pName,
60 double pRmin,
double pRmax,
61 double pSPhi,
double pDPhi,
62 double pSTheta,
double pDTheta);
114 std::ostream&
StreamInfo(std::ostream& os)
const;
150 inline void Initialize();
154 inline void CheckThetaAngles(
double sTheta,
double dTheta);
155 inline void CheckSPhiAngle(
double sPhi);
156 inline void CheckDPhiAngle(
double dPhi);
157 inline void CheckPhiAngles(
double sPhi,
double dPhi);
161 inline void InitializePhiTrigonometry();
162 inline void InitializeThetaTrigonometry();
175 enum ESide {kNull, kRMin, kRMax, kSPhi, kEPhi, kSTheta, kETheta};
179 enum ENorm {kNRMin, kNRMax, kNSPhi, kNEPhi, kNSTheta, kNETheta};
181 double fRminTolerance, kTolerance, kAngTolerance,
182 kRadTolerance, fEpsilon;
186 double fRmin, fRmax, fSPhi, fDPhi, fSTheta, fDTheta;
190 double sinCPhi, cosCPhi, cosHDPhiOT, cosHDPhiIT,
191 sinSPhi, cosSPhi, sinEPhi, cosEPhi, hDPhi, cPhi, ePhi;
195 double sinSTheta, cosSTheta, sinETheta, cosETheta,
196 tanSTheta, tanSTheta2, tanETheta, tanETheta2, eTheta;
200 bool fFullPhiSphere, fFullThetaSphere, fFullSphere;
247 void USphere::Initialize()
254 void USphere::InitializePhiTrigonometry()
257 cPhi = fSPhi + hDPhi;
258 ePhi = fSPhi + fDPhi;
260 sinCPhi = std::sin(cPhi);
261 cosCPhi = std::cos(cPhi);
262 cosHDPhiIT = std::cos(hDPhi - 0.5 * kAngTolerance);
263 cosHDPhiOT = std::cos(hDPhi + 0.5 * kAngTolerance);
264 sinSPhi = std::sin(fSPhi);
265 cosSPhi = std::cos(fSPhi);
266 sinEPhi = std::sin(ePhi);
267 cosEPhi = std::cos(ePhi);
271 void USphere::InitializeThetaTrigonometry()
273 eTheta = fSTheta + fDTheta;
275 sinSTheta = std::sin(fSTheta);
276 cosSTheta = std::cos(fSTheta);
277 sinETheta = std::sin(eTheta);
278 cosETheta = std::cos(eTheta);
280 tanSTheta = std::tan(fSTheta);
281 tanSTheta2 = tanSTheta * tanSTheta;
282 tanETheta = std::tan(eTheta);
283 tanETheta2 = tanETheta * tanETheta;
287 void USphere::CheckThetaAngles(
double sTheta,
double dTheta)
289 if ((sTheta < 0) || (sTheta > UUtils::kPi))
291 std::ostringstream message;
292 message <<
"sTheta outside 0-PI range." << std::endl
293 <<
"Invalid starting Theta angle for solid: " <<
GetName();
301 if (dTheta + sTheta >= UUtils::kPi)
303 fDTheta = UUtils::kPi - sTheta;
311 std::ostringstream message;
312 message <<
"Invalid dTheta." << std::endl
313 <<
"Negative delta-Theta (" << dTheta <<
"), for solid: "
318 if (fDTheta - fSTheta < UUtils::kPi)
320 fFullThetaSphere =
false;
324 fFullThetaSphere = true ;
326 fFullSphere = fFullPhiSphere && fFullThetaSphere;
328 InitializeThetaTrigonometry();
332 void USphere::CheckSPhiAngle(
double sPhi)
338 fSPhi = 2 * UUtils::kPi - std::fmod(std::fabs(sPhi), 2 * UUtils::kPi);
342 fSPhi = std::fmod(sPhi, 2 * UUtils::kPi) ;
344 if (fSPhi + fDPhi > 2 * UUtils::kPi)
346 fSPhi -= 2 * UUtils::kPi ;
351 void USphere::CheckDPhiAngle(
double dPhi)
353 fFullPhiSphere =
true;
354 if (dPhi >= 2 * UUtils::kPi - kAngTolerance * 0.5)
356 fDPhi = 2 * UUtils::kPi;
361 fFullPhiSphere =
false;
368 std::ostringstream message;
369 message <<
"Invalid dphi." << std::endl
370 <<
"Negative delta-Phi (" << dPhi <<
"), for solid: "
379 void USphere::CheckPhiAngles(
double sPhi,
double dPhi)
381 CheckDPhiAngle(dPhi);
385 CheckSPhiAngle(sPhi);
387 fFullSphere = fFullPhiSphere && fFullThetaSphere;
389 InitializePhiTrigonometry();
396 fRminTolerance = (fRmin) ?
std::max(kRadTolerance, fEpsilon * fRmin) : 0;
410 kTolerance =
std::max(kRadTolerance, fEpsilon * fRmax);
420 CheckSPhiAngle(newSPhi);
421 fFullPhiSphere =
false;
424 InitializePhiTrigonometry();
432 CheckPhiAngles(fSPhi, newDPhi);
439 CheckThetaAngles(newSTheta, fDTheta);
446 CheckThetaAngles(fSTheta, newDTheta);
491 if (fCubicVolume != 0.)
497 fCubicVolume = fDPhi * (std::cos(fSTheta) - std::cos(fSTheta + fDTheta)) *
498 (fRmax * fRmax * fRmax - fRmin * fRmin * fRmin) / 3.;
double GetInsideRadius() const
double GetInnerRadius() const
void SetStartPhiAngle(double newSphi, bool trig=true)
const std::string & GetName() const
void SetStartThetaAngle(double newSTheta)
VUSolid::EnumInside Inside(const UVector3 &p) const
void Extent(UVector3 &aMin, UVector3 &aMax) const
double DistanceToOut(const UVector3 &p, const UVector3 &v, UVector3 &n, bool &validNorm, double aPstep=UUtils::kInfinity) const
void SetInnerRadius(double newRMin)
void SetDeltaThetaAngle(double newDTheta)
double GetDeltaThetaAngle() const
USphere & operator=(const USphere &rhs)
double GetOuterRadius() const
double DistanceToIn(const UVector3 &p, const UVector3 &v, double aPstep=UUtils::kInfinity) const
UVector3 GetPointOnSurface() const
double SafetyFromOutside(const UVector3 &p, bool aAccurate=false) const
UGeometryType GetEntityType() const
UVisExtent GetExtent() const
USphere(const std::string &pName, double pRmin, double pRmax, double pSPhi, double pDPhi, double pSTheta, double pDTheta)
void SetInsideRadius(double newRmin)
void GetParametersList(int, double *) const
T max(const T t1, const T t2)
brief Return the largest of the two arguments
void SetDeltaPhiAngle(double newDphi)
double GetStartThetaAngle() const
void SetOuterRadius(double newRmax)
std::ostream & StreamInfo(std::ostream &os) const
virtual void ComputeBBox(UBBox *, bool)
std::string UGeometryType
bool Normal(const UVector3 &p, UVector3 &n) const
double GetStartPhiAngle() const
void Exception(const char *originOfException, const char *exceptionCode, ExceptionSeverity severity, int level, const char *description)
double GetDeltaPhiAngle() const
double SafetyFromInside(const UVector3 &p, bool aAccurate=false) const