40 #if !defined(G4GEOM_USE_USPHERE)
57 using namespace CLHEP;
86 if ( (pRmin >= pRmax) || (pRmax < 1.1*
kRadTolerance) || (pRmin < 0) )
90 <<
" pRmin = " << pRmin <<
", pRmax = " << pRmax;
91 G4Exception(
"G4Sphere::G4Sphere()",
"GeomSolids0002",
110 :
G4CSGSolid(a), fRminTolerance(0.), fRmaxTolerance(0.),
111 kAngTolerance(0.), kRadTolerance(0.),
112 fRmin(0.), fRmax(0.), fSPhi(0.), fDPhi(0.), fSTheta(0.),
113 fDTheta(0.), sinCPhi(0.), cosCPhi(0.),
114 cosHDPhi(0.), cosHDPhiOT(0.), cosHDPhiIT(0.),
115 sinSPhi(0.), cosSPhi(0.), sinEPhi(0.), cosEPhi(0.), hDPhi(0.), cPhi(0.),
116 ePhi(0.), sinSTheta(0.), cosSTheta(0.), sinETheta(0.), cosETheta(0.),
117 tanSTheta(0.), tanSTheta2(0.), tanETheta(0.), tanETheta2(0.), eTheta(0.),
118 halfCarTolerance(0.), halfAngTolerance(0.)
135 :
G4CSGSolid(rhs), fRminTolerance(rhs.fRminTolerance),
136 fRmaxTolerance(rhs.fRmaxTolerance), kAngTolerance(rhs.kAngTolerance),
137 kRadTolerance(rhs.kRadTolerance), fEpsilon(rhs.fEpsilon),
138 fRmin(rhs.fRmin), fRmax(rhs.fRmax), fSPhi(rhs.fSPhi), fDPhi(rhs.fDPhi),
139 fSTheta(rhs.fSTheta), fDTheta(rhs.fDTheta),
140 sinCPhi(rhs.sinCPhi), cosCPhi(rhs.cosCPhi), cosHDPhi(rhs.cosHDPhi),
141 cosHDPhiOT(rhs.cosHDPhiOT), cosHDPhiIT(rhs.cosHDPhiIT),
142 sinSPhi(rhs.sinSPhi), cosSPhi(rhs.cosSPhi),
143 sinEPhi(rhs.sinEPhi), cosEPhi(rhs.cosEPhi),
144 hDPhi(rhs.hDPhi), cPhi(rhs.cPhi), ePhi(rhs.ePhi),
145 sinSTheta(rhs.sinSTheta), cosSTheta(rhs.cosSTheta),
146 sinETheta(rhs.sinETheta), cosETheta(rhs.cosETheta),
147 tanSTheta(rhs.tanSTheta), tanSTheta2(rhs.tanSTheta2),
148 tanETheta(rhs.tanETheta), tanETheta2(rhs.tanETheta2), eTheta(rhs.eTheta),
149 fFullPhiSphere(rhs.fFullPhiSphere), fFullThetaSphere(rhs.fFullThetaSphere),
150 fFullSphere(rhs.fFullSphere),
151 halfCarTolerance(rhs.halfCarTolerance),
152 halfAngTolerance(rhs.halfAngTolerance)
164 if (
this == &rhs) {
return *
this; }
219 pMin.
set(-rmax,-rmax,-rmax);
220 pMax.
set( rmax, rmax, rmax);
233 if (stheta >
halfpi) rhomax = rmax*sinStart;
234 if (etheta <
halfpi) rhomax = rmax*sinEnd;
244 pMin.
set(xymin.
x(),xymin.
y(),zmin);
245 pMax.
set(xymax.
x(),xymax.
y(),zmax);
250 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
253 message <<
"Bad bounding box (min >= max) for solid: "
255 <<
"\npMin = " << pMin
256 <<
"\npMax = " <<
pMax;
257 G4Exception(
"G4Sphere::BoundingLimits()",
"GeomMgt0001",
290 G4double rho,rho2,rad2,tolRMin,tolRMax;
299 rho2 = p.
x()*p.
x() + p.
y()*p.
y() ;
300 rad2 = rho2 + p.
z()*p.
z() ;
305 tolRMax = Rmax_minus;
323 if ( (rad2 <= Rmax_minus*Rmax_minus) && (rad2 >= Rmin_plus*Rmin_plus) )
329 tolRMax =
fRmax + halfRmaxTolerance;
331 if ( (rad2 <= tolRMax*tolRMax) && (rad2 >= tolRMin*tolRMin) )
345 pPhi = std::atan2(p.
y(),p.
x()) ;
364 rho = std::sqrt(rho2);
365 pTheta = std::atan2(rho,p.
z());
404 G4int noSurfaces = 0;
412 rho2 = p.
x()*p.
x()+p.
y()*p.
y();
413 radius = std::sqrt(rho2+p.
z()*p.
z());
414 rho = std::sqrt(rho2);
417 if (
fRmin) distRMin = std::fabs(radius-
fRmin);
421 pPhi = std::atan2(p.
y(),p.
x());
430 distSPhi = std::fabs( pPhi-
fSPhi );
431 distEPhi = std::fabs( pPhi-
ePhi );
445 pTheta = std::atan2(rho,p.
z());
446 distSTheta = std::fabs(pTheta-
fSTheta);
447 distETheta = std::fabs(pTheta-
eTheta);
502 else { sumnorm += nTs; }
508 else { sumnorm += nTe; }
509 if(sumnorm.
z() == 0.) { sumnorm += nZ; }
512 if ( noSurfaces == 0 )
515 G4Exception(
"G4Sphere::SurfaceNormal(p)",
"GeomSolids1002",
520 else if ( noSurfaces == 1 ) { norm = sumnorm; }
521 else { norm = sumnorm.
unit(); }
536 G4double distRMin,distRMax,distSPhi,distEPhi,
537 distSTheta,distETheta,distMin;
539 rho2=p.
x()*p.
x()+p.
y()*p.
y();
540 radius=std::sqrt(rho2+p.
z()*p.
z());
547 distRMax=std::fabs(radius-
fRmax);
550 distRMin=std::fabs(radius-
fRmin);
552 if (distRMin<distRMax)
574 pPhi = std::atan2(p.
y(),p.
x());
575 if (pPhi<0) { pPhi +=
twopi; }
585 distSPhi=std::fabs(pPhi-
fSPhi)*rho;
592 if (distSPhi<distEPhi)
594 if (distSPhi<distMin)
602 if (distEPhi<distMin)
616 pTheta=std::atan2(rho,p.
z());
622 if (distSTheta<distETheta)
624 if (distSTheta<distMin)
626 distMin = distSTheta ;
632 if (distETheta<distMin)
634 distMin = distETheta ;
668 "Undefined side for valid surface normal to solid.");
708 G4double rho2, rad2, pDotV2d, pDotV3d, pTheta ;
709 G4double tolSTheta=0., tolETheta=0. ;
715 ? (
fRmin-halfRminTolerance)*(
fRmin-halfRminTolerance) : 0;
717 (
fRmin+halfRminTolerance)*(
fRmin+halfRminTolerance);
719 (
fRmax+halfRmaxTolerance)*(
fRmax+halfRmaxTolerance);
721 (
fRmax-halfRmaxTolerance)*(
fRmax-halfRmaxTolerance);
725 G4double xi, yi, zi, rhoi, rhoi2, radi2, iTheta ;
742 rho2 = p.
x()*p.
x() + p.
y()*p.
y() ;
743 rad2 = rho2 + p.
z()*p.
z() ;
744 pTheta = std::atan2(std::sqrt(rho2),p.
z()) ;
746 pDotV2d = p.
x()*v.
x() + p.
y()*v.
y() ;
747 pDotV3d = pDotV2d + p.
z()*v.
z() ;
758 if ((rad2!=0.0) || (
fRmin!=0.0))
764 G4double vTheta = std::atan2(std::sqrt(v.
x()*v.
x()+v.
y()*v.
y()),v.
z()) ;
765 if ( (vTheta < tolSTheta) || (vTheta > tolETheta) )
794 d2 = pDotV3d*pDotV3d -
c ;
798 sd = -pDotV3d - std::sqrt(d2) ;
804 G4double fTerm = sd-std::fmod(sd,dRmax);
807 xi = p.
x() + sd*v.
x() ;
808 yi = p.
y() + sd*v.
y() ;
809 rhoi = std::sqrt(xi*xi + yi*yi) ;
819 zi = p.
z() + sd*v.
z() ;
824 iTheta = std::atan2(rhoi,zi) ;
825 if ( (iTheta >= tolSTheta) && (iTheta <= tolETheta) )
840 zi = p.
z() + sd*v.
z() ;
845 iTheta = std::atan2(rhoi,zi) ;
846 if ( (iTheta >= tolSTheta) && (iTheta <= tolETheta) )
868 d2 = pDotV3d*pDotV3d -
c ;
870 if ( (rad2 > tolIRMax2)
924 d2 = pDotV3d*pDotV3d -
c ;
929 if ( (c > -halfRminTolerance) && (rad2 < tolIRMin2)
976 sd = -pDotV3d + std::sqrt(d2) ;
977 if ( sd >= halfRminTolerance )
979 xi = p.
x() + sd*v.
x() ;
980 yi = p.
y() + sd*v.
y() ;
981 rhoi = std::sqrt(xi*xi+yi*yi) ;
991 zi = p.
z() + sd*v.
z() ;
996 iTheta = std::atan2(rhoi,zi) ;
997 if ( (iTheta >= tolSTheta) && (iTheta<=tolETheta) )
1012 zi = p.
z() + sd*v.
z() ;
1017 iTheta = std::atan2(rhoi,zi) ;
1018 if ( (iTheta >= tolSTheta) && (iTheta <= tolETheta) )
1061 xi = p.
x() + sd*v.
x() ;
1062 yi = p.
y() + sd*v.
y() ;
1063 zi = p.
z() + sd*v.
z() ;
1064 rhoi2 = xi*xi + yi*yi ;
1065 radi2 = rhoi2 + zi*zi ;
1076 if ( (radi2 <= tolORMax2)
1077 && (radi2 >= tolORMin2)
1086 iTheta = std::atan2(std::sqrt(rhoi2),zi) ;
1087 if ( (iTheta >= tolSTheta) && (iTheta <= tolETheta) )
1092 if ((yi*
cosCPhi-xi*sinCPhi) <= 0)
1123 xi = p.
x() + sd*v.
x() ;
1124 yi = p.
y() + sd*v.
y() ;
1125 zi = p.
z() + sd*v.
z() ;
1126 rhoi2 = xi*xi + yi*yi ;
1127 radi2 = rhoi2 + zi*zi ;
1138 if ( (radi2 <= tolORMax2)
1139 && (radi2 >= tolORMin2)
1148 iTheta = std::atan2(std::sqrt(rhoi2),zi) ;
1149 if ( (iTheta >= tolSTheta) && (iTheta <= tolETheta) )
1154 if ((yi*
cosCPhi-xi*sinCPhi) >= 0)
1211 if ( pTheta < tolSTheta )
1221 c = dist2STheta/
t1 ;
1228 zi = p.
z() + sd*v.
z();
1234 if ((sd >= 0) && (sd < snxt))
1236 xi = p.
x() + sd*v.
x();
1237 yi = p.
y() + sd*v.
y();
1238 zi = p.
z() + sd*v.
z();
1239 rhoi2 = xi*xi + yi*yi;
1240 radi2 = rhoi2 + zi*zi;
1241 if ( (radi2 <= tolORMax2)
1242 && (radi2 >= tolORMin2)
1272 c = dist2ETheta/
t1 ;
1280 if ( (sd >= 0) && (sd < snxt) )
1282 xi = p.
x() + sd*v.
x() ;
1283 yi = p.
y() + sd*v.
y() ;
1284 zi = p.
z() + sd*v.
z() ;
1285 rhoi2 = xi*xi + yi*yi ;
1286 radi2 = rhoi2 + zi*zi ;
1288 if ( (radi2 <= tolORMax2)
1289 && (radi2 >= tolORMin2)
1310 else if ( pTheta > tolETheta )
1321 c = dist2ETheta/
t1 ;
1328 zi = p.
z() + sd*v.
z();
1334 if ( (sd >= 0) && (sd < snxt) )
1336 xi = p.
x() + sd*v.
x() ;
1337 yi = p.
y() + sd*v.
y() ;
1338 zi = p.
z() + sd*v.
z() ;
1339 rhoi2 = xi*xi + yi*yi ;
1340 radi2 = rhoi2 + zi*zi ;
1342 if ( (radi2 <= tolORMax2)
1343 && (radi2 >= tolORMin2)
1373 c = dist2STheta/
t1 ;
1381 if ( (sd >= 0) && (sd < snxt) )
1383 xi = p.
x() + sd*v.
x() ;
1384 yi = p.
y() + sd*v.
y() ;
1385 zi = p.
z() + sd*v.
z() ;
1386 rhoi2 = xi*xi + yi*yi ;
1387 radi2 = rhoi2 + zi*zi ;
1389 if ( (radi2 <= tolORMax2)
1390 && (radi2 >= tolORMin2)
1419 if ( (t2>=0 && tolIRMin2<rad2 && rad2<tolIRMax2 &&
fSTheta<
halfpi)
1420 || (t2<0 && tolIRMin2<rad2 && rad2<tolIRMax2 && fSTheta>
halfpi)
1421 || (v.
z()<0 && tolIRMin2<rad2 && rad2<tolIRMax2 &&
fSTheta==
halfpi) )
1443 c = dist2STheta/
t1 ;
1452 xi = p.
x() + sd*v.
x() ;
1453 yi = p.
y() + sd*v.
y() ;
1454 zi = p.
z() + sd*v.
z() ;
1455 rhoi2 = xi*xi + yi*yi ;
1456 radi2 = rhoi2 + zi*zi ;
1458 if ( (radi2 <= tolORMax2)
1459 && (radi2 >= tolORMin2)
1460 && (zi*(fSTheta - halfpi) <= 0) )
1489 && (tolIRMin2 < rad2) && (rad2 < tolIRMax2))
1491 && (tolIRMin2 < rad2) && (rad2 < tolIRMax2))
1493 && (tolIRMin2 < rad2) && (rad2 < tolIRMax2)) )
1515 c = dist2ETheta/
t1 ;
1526 xi = p.
x() + sd*v.
x() ;
1527 yi = p.
y() + sd*v.
y() ;
1528 zi = p.
z() + sd*v.
z() ;
1529 rhoi2 = xi*xi + yi*yi ;
1530 radi2 = rhoi2 + zi*zi ;
1532 if ( (radi2 <= tolORMax2)
1533 && (radi2 >= tolORMin2)
1563 c = dist2STheta/
t1 ;
1571 if ((sd >= 0) && (sd < snxt))
1573 xi = p.
x() + sd*v.
x() ;
1574 yi = p.
y() + sd*v.
y() ;
1575 zi = p.
z() + sd*v.
z() ;
1576 rhoi2 = xi*xi + yi*yi ;
1577 radi2 = rhoi2 + zi*zi ;
1579 if ( (radi2 <= tolORMax2)
1580 && (radi2 >= tolORMin2)
1604 c = dist2ETheta/
t1 ;
1612 if ((sd >= 0) && (sd < snxt))
1614 xi = p.
x() + sd*v.
x() ;
1615 yi = p.
y() + sd*v.
y() ;
1616 zi = p.
z() + sd*v.
z() ;
1617 rhoi2 = xi*xi + yi*yi ;
1618 radi2 = rhoi2 + zi*zi ;
1620 if ( (radi2 <= tolORMax2)
1621 && (radi2 >= tolORMin2)
1655 G4double safe=0.0,safeRMin,safeRMax,safePhi,safeTheta;
1659 rho2=p.
x()*p.
x()+p.
y()*p.
y();
1660 rds=std::sqrt(rho2+p.
z()*p.
z());
1661 rho=std::sqrt(rho2);
1670 if (safeRMin>safeRMax)
1704 if (safePhi>safe) { safe=safePhi; }
1712 pTheta=std::acos(p.
z()/rds);
1713 if (pTheta<0) { pTheta+=
pi; }
1716 if (dTheta1>dTheta2)
1720 safeTheta=rds*std::sin(dTheta1);
1721 if (safe<=safeTheta)
1731 safeTheta=rds*std::sin(dTheta2);
1732 if (safe<=safeTheta)
1740 if (safe<0) { safe=0; }
1768 G4double pDistS,compS,pDistE,compE,sphi2,vphi;
1770 G4double rho2,rad2,pDotV2d,pDotV3d;
1777 G4double dist2STheta, dist2ETheta, distTheta;
1782 rho2 = p.
x()*p.
x()+p.
y()*p.
y();
1783 rad2 = rho2+p.
z()*p.
z();
1785 pDotV2d = p.
x()*v.
x()+p.
y()*v.
y();
1786 pDotV3d = pDotV2d+p.
z()*v.
z();
1804 if( (rad2 <= Rmax_plus*Rmax_plus) && (rad2 >= Rmin_minus*Rmin_minus) )
1819 d2 = pDotV3d*pDotV3d -
c;
1822 && ((pDotV3d >=0) || (d2 < 0)) )
1834 snxt = -pDotV3d+std::sqrt(d2);
1846 d2 = pDotV3d*pDotV3d -
c;
1853 if(calcNorm) { *validNorm =
false; }
1860 sd = -pDotV3d-std::sqrt(d2);
1906 if ( std::fabs( p.
z() ) <= halfRmaxTolerance )
1915 stheta = -p.
z()/v.
z();
1931 if(std::fabs(distTheta) < halfRmaxTolerance)
1935 if( calcNorm ) { *validNorm =
false; }
1945 rhoSecTheta = std::sqrt(rho2*(1+
tanSTheta2));
1956 stheta = -0.5*dist2STheta/
t2;
1962 if( std::fabs(distTheta) < halfRmaxTolerance )
1971 rhoSecTheta = std::sqrt(rho2*(1+
tanSTheta2));
1983 if( calcNorm ) { *validNorm =
false; }
1999 if ( ((std::fabs(
s) < halfRmaxTolerance) && (t2 < 0.))
2000 || (sd < 0.) || ( (sd > 0.) && (p.
z() + sd*v.
z() > 0.) ) )
2004 if( (sd > halfRmaxTolerance) && (p.
z() + sd*v.
z() <= 0.) )
2014 if ( ( (std::fabs(sd) < halfRmaxTolerance) && (t2 >= 0.) )
2015 || (sd < 0.) || ( (sd > 0.) && (p.
z() + sd*v.
z() < 0.) ) )
2019 if( (sd > halfRmaxTolerance) && (p.
z() + sd*v.
z() >= 0.) )
2035 if ( std::fabs( p.
z() ) <= halfRmaxTolerance )
2065 if(std::fabs(distTheta) < halfRmaxTolerance)
2069 if( calcNorm ) { *validNorm =
false; }
2079 rhoSecTheta = std::sqrt(rho2*(1+
tanETheta2));
2089 sd = -0.5*dist2ETheta/
t2;
2100 if ( std::fabs(distTheta) < halfRmaxTolerance )
2109 rhoSecTheta = std::sqrt(rho2*(1+
tanETheta2));
2119 && (t2 < 0.) && (p.
z() <=0.) )
2121 if( calcNorm ) { *validNorm =
false; }
2128 if ( (d2 <halfRmaxTolerance) && (d2 > -halfRmaxTolerance) )
2140 if( ((std::fabs(sd) < halfRmaxTolerance) && (t2 < 0.))
2145 if( sd > halfRmaxTolerance )
2158 if ( ((std::fabs(sd) < halfRmaxTolerance) && (t2 >= 0.))
2160 || ( (sd > 0.) && (p.
z() + sd*v.
z() > halfRmaxTolerance) ) )
2164 if ( ( sd>halfRmaxTolerance )
2165 && ( p.
z()+sd*v.
z() <= halfRmaxTolerance ) )
2185 if ( p.
x() || p.
y() )
2198 if ( (pDistS <= 0) && (pDistE <= 0) )
2204 sphi = pDistS/compS ;
2205 xi = p.
x()+sphi*v.
x() ;
2206 yi = p.
y()+sphi*v.
y() ;
2212 vphi = std::atan2(v.
y(),v.
x());
2234 sphi2=pDistE/compE ;
2237 xi = p.
x()+sphi2*v.
x() ;
2238 yi = p.
y()+sphi2*v.
y() ;
2247 vphi = std::atan2(v.
y(),v.
x()) ;
2254 else { sphi = 0.0; }
2272 else if ((pDistS >= 0) && (pDistE >= 0))
2274 if ( pDistS <= pDistE )
2284 if ( (compS < 0) && (compE < 0) ) { sphi = 0; }
2292 if ( (compS >= 0) && (compE >= 0) ) { sphi =
kInfinity; }
2296 else if ( (pDistS > 0) && (pDistE < 0) )
2304 sphi = pDistE/compE ;
2305 xi = p.
x() + sphi*v.
x() ;
2306 yi = p.
y() + sphi*v.
y() ;
2313 vphi = std::atan2(v.
y(),v.
x());
2342 sphi = pDistE/compE ;
2343 xi = p.
x() + sphi*v.
x() ;
2344 yi = p.
y() + sphi*v.
y() ;
2352 vphi = std::atan2(v.
y(),v.
x());
2388 xi=p.
x()+sphi*v.
x();
2389 yi=p.
y()+sphi*v.
y();
2396 vphi = std::atan2(v.
y(),v.
x()) ;
2425 sphi = pDistS/compS ;
2426 xi = p.
x()+sphi*v.
x() ;
2427 yi = p.
y()+sphi*v.
y() ;
2435 vphi = std::atan2(v.
y(),v.
x()) ;
2470 if ( v.
x() || v.
y() )
2472 vphi = std::atan2(v.
y(),v.
x()) ;
2505 xi=p.
x()+snxt*v.
x();
2506 yi=p.
y()+snxt*v.
y();
2507 zi=p.
z()+snxt*v.
z();
2522 else { *validNorm=
false; }
2531 else { *validNorm=
false; }
2542 xi = p.
x() + snxt*v.
x();
2543 yi = p.
y() + snxt*v.
y();
2547 rhoSecTheta = std::sqrt(rho2*(1+
tanSTheta2));
2557 else { *validNorm=
false; }
2568 xi=p.
x()+snxt*v.
x();
2569 yi=p.
y()+snxt*v.
y();
2573 rhoSecTheta = std::sqrt(rho2*(1+
tanETheta2));
2583 else { *validNorm=
false; }
2590 G4int oldprc = message.precision(16);
2591 message <<
"Undefined side for valid surface normal to solid."
2593 <<
"Position:" << G4endl << G4endl
2594 <<
"p.x() = " << p.
x()/
mm <<
" mm" << G4endl
2595 <<
"p.y() = " << p.
y()/
mm <<
" mm" << G4endl
2596 <<
"p.z() = " << p.
z()/
mm <<
" mm" << G4endl << G4endl
2597 <<
"Direction:" << G4endl << G4endl
2598 <<
"v.x() = " << v.
x() << G4endl
2599 <<
"v.y() = " << v.
y() << G4endl
2600 <<
"v.z() = " << v.
z() << G4endl << G4endl
2601 <<
"Proposed distance :" << G4endl << G4endl
2602 <<
"snxt = " << snxt/
mm <<
" mm" <<
G4endl;
2603 message.precision(oldprc);
2614 G4int oldprc = message.precision(16);
2615 message <<
"Logic error: snxt = kInfinity ???" << G4endl
2616 <<
"Position:" << G4endl << G4endl
2617 <<
"p.x() = " << p.
x()/
mm <<
" mm" << G4endl
2618 <<
"p.y() = " << p.
y()/
mm <<
" mm" << G4endl
2619 <<
"p.z() = " << p.
z()/
mm <<
" mm" << G4endl << G4endl
2620 <<
"Rp = "<< std::sqrt( p.
x()*p.
x()+p.
y()*p.
y()+p.
z()*p.
z() )/
mm
2621 <<
" mm" << G4endl << G4endl
2622 <<
"Direction:" << G4endl << G4endl
2623 <<
"v.x() = " << v.
x() << G4endl
2624 <<
"v.y() = " << v.
y() << G4endl
2625 <<
"v.z() = " << v.
z() << G4endl << G4endl
2626 <<
"Proposed distance :" << G4endl << G4endl
2627 <<
"snxt = " << snxt/
mm <<
" mm" <<
G4endl;
2628 message.precision(oldprc);
2642 G4double safe=0.0,safeRMin,safeRMax,safePhi,safeTheta;
2645 rho2=p.
x()*p.
x()+p.
y()*p.
y();
2646 rds=std::sqrt(rho2+p.
z()*p.
z());
2647 rho=std::sqrt(rho2);
2659 G4cout.precision(old_prc) ;
2661 "GeomSolids1002",
JustWarning,
"Point p is outside !?" );
2667 safeRMax =
fRmax-rds;
2671 safeRMin = rds-
fRmin;
2672 safe =
std::min( safeRMin, safeRMax );
2706 pTheta=std::acos(p.
z()/rds);
2707 if (pTheta<0) { pTheta+=
pi; }
2711 { dTheta2=
eTheta-pTheta;}
2713 safeTheta=rds*std::sin(
std::min(dTheta1, dTheta2) );
2720 safe =
std::min( safe, safeTheta );
2723 if (safe<0.0) { safe=0; }
2753 G4int oldprc = os.precision(16);
2754 os <<
"-----------------------------------------------------------\n"
2755 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
2756 <<
" ===================================================\n"
2757 <<
" Solid type: G4Sphere\n"
2758 <<
" Parameters: \n"
2759 <<
" inner radius: " <<
fRmin/
mm <<
" mm \n"
2760 <<
" outer radius: " <<
fRmax/
mm <<
" mm \n"
2761 <<
" starting phi of segment : " <<
fSPhi/
degree <<
" degrees \n"
2762 <<
" delta phi of segment : " <<
fDPhi/
degree <<
" degrees \n"
2763 <<
" starting theta of segment: " <<
fSTheta/
degree <<
" degrees \n"
2764 <<
" delta theta of segment : " <<
fDTheta/
degree <<
" degrees \n"
2765 <<
"-----------------------------------------------------------\n";
2766 os.precision(oldprc);
2777 G4double zRand, aOne, aTwo, aThr, aFou, aFiv, chose,
phi, sinphi, cosphi;
2778 G4double height1, height2, slant1, slant2, costheta, sintheta, rRand;
2793 cosphi = std::cos(phi);
2794 sinphi = std::sin(phi);
2796 sintheta = std::sqrt(1.-
sqr(costheta));
2805 if( (chose>=0.) && (chose<aOne) )
2810 else if( (chose>=aOne) && (chose<aOne+aTwo) )
2815 else if( (chose>=aOne+aTwo) && (chose<aOne+aTwo+aThr) )
2828 else if( (chose>=aOne+aTwo+aThr) && (chose<aOne+aTwo+aThr+aFou) )
2841 else if( (chose>=aOne+aTwo+aThr+aFou) && (chose<aOne+aTwo+aThr+aFou+aFiv) )
2844 rRand*sintheta*
sinSPhi,rRand*costheta);
2849 rRand*sintheta*
sinEPhi,rRand*costheta);