40#if !defined(G4GEOM_USE_USPHERE)
76 :
G4CSGSolid(pName), fSPhi(0.0), fFullPhiSphere(true), fFullThetaSphere(true)
82 halfAngTolerance = 0.5*kAngTolerance;
86 if ( (pRmin >= pRmax) || (pRmax < 1.1*kRadTolerance) || (pRmin < 0) )
88 std::ostringstream message;
90 <<
" pRmin = " << pRmin <<
", pRmax = " << pRmax;
91 G4Exception(
"G4Sphere::G4Sphere()",
"GeomSolids0002",
94 fRmin=pRmin; fRmax=pRmax;
95 fRminTolerance = (fRmin) ? std::max( kRadTolerance, fEpsilon*fRmin ) : 0;
96 fRmaxTolerance = std::max( kRadTolerance, fEpsilon*fRmax );
100 CheckPhiAngles(pSPhi, pDPhi);
101 CheckThetaAngles(pSTheta, pDTheta);
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; }
172 fRminTolerance = rhs.fRminTolerance; fRmaxTolerance = rhs.fRmaxTolerance;
173 kAngTolerance = rhs.kAngTolerance; kRadTolerance = rhs.kRadTolerance;
174 fEpsilon = rhs.fEpsilon; fRmin = rhs.fRmin; fRmax = rhs.fRmax;
175 fSPhi = rhs.fSPhi; fDPhi = rhs.fDPhi; fSTheta = rhs.fSTheta;
176 fDTheta = rhs.fDTheta; sinCPhi = rhs.sinCPhi; cosCPhi = rhs.cosCPhi;
177 cosHDPhi = rhs.cosHDPhi;
178 cosHDPhiOT = rhs.cosHDPhiOT; cosHDPhiIT = rhs.cosHDPhiIT;
179 sinSPhi = rhs.sinSPhi; cosSPhi = rhs.cosSPhi;
180 sinEPhi = rhs.sinEPhi; cosEPhi = rhs.cosEPhi;
181 hDPhi = rhs.hDPhi; cPhi = rhs.cPhi; ePhi = rhs.ePhi;
182 sinSTheta = rhs.sinSTheta; cosSTheta = rhs.cosSTheta;
183 sinETheta = rhs.sinETheta; cosETheta = rhs.cosETheta;
184 tanSTheta = rhs.tanSTheta; tanSTheta2 = rhs.tanSTheta2;
185 tanETheta = rhs.tanETheta; tanETheta2 = rhs.tanETheta2;
186 eTheta = rhs.eTheta; fFullPhiSphere = rhs.fFullPhiSphere;
187 fFullThetaSphere = rhs.fFullThetaSphere; fFullSphere = rhs.fFullSphere;
188 halfCarTolerance = rhs.halfCarTolerance;
189 halfAngTolerance = rhs.halfAngTolerance;
219 pMin.
set(-rmax,-rmax,-rmax);
220 pMax.
set( rmax, rmax, rmax);
231 G4double rhomin = rmin*std::min(sinStart,sinEnd);
233 if (stheta > halfpi) rhomax = rmax*sinStart;
234 if (etheta < halfpi) rhomax = rmax*sinEnd;
242 G4double zmin = std::min(rmin*cosEnd,rmax*cosEnd);
243 G4double zmax = std::max(rmin*cosStart,rmax*cosStart);
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())
252 std::ostringstream message;
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;
294 const G4double halfRmaxTolerance = fRmaxTolerance*0.5;
295 const G4double halfRminTolerance = fRminTolerance*0.5;
296 const G4double Rmax_minus = fRmax - halfRmaxTolerance;
297 const G4double Rmin_plus = (fRmin > 0) ? fRmin+halfRminTolerance : 0;
299 rho2 = p.
x()*p.
x() + p.
y()*p.
y() ;
300 rad2 = rho2 + p.
z()*p.
z() ;
305 tolRMax = Rmax_minus;
313 if ( (!fFullPhiSphere) || (!fFullThetaSphere) )
323 if ( (rad2 <= Rmax_minus*Rmax_minus) && (rad2 >= Rmin_plus*Rmin_plus) )
329 tolRMax = fRmax + halfRmaxTolerance;
330 tolRMin = std::max(fRmin-halfRminTolerance, 0.);
331 if ( (rad2 <= tolRMax*tolRMax) && (rad2 >= tolRMin*tolRMin) )
343 if ( !fFullPhiSphere && rho2 )
345 pPhi = std::atan2(p.
y(),p.
x()) ;
347 if ( pPhi < fSPhi - halfAngTolerance ) { pPhi += twopi; }
348 else if ( pPhi > ePhi + halfAngTolerance ) { pPhi -= twopi; }
350 if ( (pPhi < fSPhi - halfAngTolerance)
351 || (pPhi > ePhi + halfAngTolerance) ) {
return in =
kOutside; }
355 if ( (pPhi < fSPhi + halfAngTolerance)
356 || (pPhi > ePhi - halfAngTolerance) ) { in =
kSurface; }
362 if ( (rho2 || p.
z()) && (!fFullThetaSphere) )
364 rho = std::sqrt(rho2);
365 pTheta = std::atan2(rho,p.
z());
369 if ( ((fSTheta > 0.0) && (pTheta < fSTheta + halfAngTolerance))
370 || ((eTheta < pi) && (pTheta > eTheta - halfAngTolerance)) )
372 if ( (( (fSTheta>0.0)&&(pTheta>=fSTheta-halfAngTolerance) )
373 || (fSTheta == 0.0) )
374 && ((eTheta==pi)||(pTheta <= eTheta + halfAngTolerance) ) )
386 if ( ((fSTheta > 0.0)&&(pTheta < fSTheta - halfAngTolerance))
387 ||((eTheta < pi )&&(pTheta > eTheta + halfAngTolerance)) )
404 G4int noSurfaces = 0;
405 G4double rho, rho2, radius, pTheta, pPhi=0.;
407 G4double distSPhi = kInfinity, distEPhi = kInfinity;
408 G4double distSTheta = kInfinity, distETheta = kInfinity;
412 rho2 = p.
x()*p.
x()+p.
y()*p.
y();
413 radius = std::sqrt(rho2+p.
z()*p.
z());
414 rho = std::sqrt(rho2);
416 G4double distRMax = std::fabs(radius-fRmax);
417 if (fRmin) distRMin = std::fabs(radius-fRmin);
419 if ( rho && !fFullSphere )
421 pPhi = std::atan2(p.
y(),p.
x());
423 if (pPhi < fSPhi-halfAngTolerance) { pPhi += twopi; }
424 else if (pPhi > ePhi+halfAngTolerance) { pPhi -= twopi; }
426 if ( !fFullPhiSphere )
430 distSPhi = std::fabs( pPhi-fSPhi );
431 distEPhi = std::fabs( pPhi-ePhi );
441 if ( !fFullThetaSphere )
445 pTheta = std::atan2(rho,p.
z());
446 distSTheta = std::fabs(pTheta-fSTheta);
447 distETheta = std::fabs(pTheta-eTheta);
450 -cosSTheta*p.
y()/rho,
471 if( radius ) { nR =
G4ThreeVector(p.
x()/radius,p.
y()/radius,p.
z()/radius); }
473 if( distRMax <= halfCarTolerance )
478 if( fRmin && (distRMin <= halfCarTolerance) )
483 if( !fFullPhiSphere )
485 if (distSPhi <= halfAngTolerance)
490 if (distEPhi <= halfAngTolerance)
496 if ( !fFullThetaSphere )
498 if ((distSTheta <= halfAngTolerance) && (fSTheta > 0.))
501 if ((radius <= halfCarTolerance) && fFullPhiSphere) { sumnorm += nZ; }
502 else { sumnorm += nTs; }
504 if ((distETheta <= halfAngTolerance) && (eTheta < pi))
507 if ((radius <= halfCarTolerance) && fFullPhiSphere) { sumnorm -= nZ; }
508 else { sumnorm += nTe; }
509 if(sumnorm.
z() == 0.) { sumnorm += nZ; }
512 if ( noSurfaces == 0 )
515 G4Exception(
"G4Sphere::SurfaceNormal(p)",
"GeomSolids1002",
518 norm = ApproxSurfaceNormal(p);
520 else if ( noSurfaces == 1 ) { norm = sumnorm; }
521 else { norm = sumnorm.
unit(); }
535 G4double rho,rho2,radius,pPhi,pTheta;
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; }
577 if (!fFullPhiSphere && rho)
581 distSPhi=std::fabs(pPhi-(fSPhi+twopi))*rho;
585 distSPhi=std::fabs(pPhi-fSPhi)*rho;
588 distEPhi=std::fabs(pPhi-fSPhi-fDPhi)*rho;
592 if (distSPhi<distEPhi)
594 if (distSPhi<distMin)
602 if (distEPhi<distMin)
614 if (!fFullThetaSphere && radius)
616 pTheta=std::atan2(rho,p.
z());
617 distSTheta=std::fabs(pTheta-fSTheta)*radius;
618 distETheta=std::fabs(pTheta-fSTheta-fDTheta)*radius;
622 if (distSTheta<distETheta)
624 if (distSTheta<distMin)
626 distMin = distSTheta ;
632 if (distETheta<distMin)
634 distMin = distETheta ;
656 -cosSTheta*std::sin(pPhi),
661 cosETheta*std::sin(pPhi),
668 "Undefined side for valid surface normal to solid.");
708 G4double rho2, rad2, pDotV2d, pDotV3d, pTheta ;
709 G4double tolSTheta=0., tolETheta=0. ;
712 const G4double halfRmaxTolerance = fRmaxTolerance*0.5;
713 const G4double halfRminTolerance = fRminTolerance*0.5;
714 const G4double tolORMin2 = (fRmin>halfRminTolerance)
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 ;
738 G4double t1, t2, b, c, d2, d, sd = kInfinity ;
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() ;
751 if (!fFullThetaSphere)
753 tolSTheta = fSTheta - halfAngTolerance ;
754 tolETheta = eTheta + halfAngTolerance ;
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) )
787 c = rad2 - fRmax*fRmax ;
789 if (c > fRmaxTolerance*fRmax)
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) ;
811 if (!fFullPhiSphere && rhoi)
813 cosPsi = (xi*cosCPhi + yi*sinCPhi)/rhoi ;
815 if (cosPsi >= cosHDPhiOT)
817 if (!fFullThetaSphere)
819 zi = p.
z() + sd*v.
z() ;
824 iTheta = std::atan2(rhoi,zi) ;
825 if ( (iTheta >= tolSTheta) && (iTheta <= tolETheta) )
838 if (!fFullThetaSphere)
840 zi = p.
z() + sd*v.
z() ;
845 iTheta = std::atan2(rhoi,zi) ;
846 if ( (iTheta >= tolSTheta) && (iTheta <= tolETheta) )
860 return snxt=kInfinity;
868 d2 = pDotV3d*pDotV3d - c ;
870 if ( (rad2 > tolIRMax2)
871 && ( (d2 >= fRmaxTolerance*fRmax) && (pDotV3d < 0) ) )
878 cosPsi = (p.
x()*cosCPhi + p.
y()*sinCPhi)/std::sqrt(rho2) ;
880 if (cosPsi>=cosHDPhiIT)
884 if ( !fFullThetaSphere )
886 if ( (pTheta >= tolSTheta + kAngTolerance)
887 && (pTheta <= tolETheta - kAngTolerance) )
900 if ( !fFullThetaSphere )
902 if ( (pTheta >= tolSTheta + kAngTolerance)
903 && (pTheta <= tolETheta - kAngTolerance) )
923 c = rad2 - fRmin*fRmin ;
924 d2 = pDotV3d*pDotV3d - c ;
929 if ( (c > -halfRminTolerance) && (rad2 < tolIRMin2)
932 if ( !fFullPhiSphere )
937 cosPsi = (p.
x()*cosCPhi+p.
y()*sinCPhi)/std::sqrt(rho2) ;
938 if (cosPsi >= cosHDPhiIT)
942 if ( !fFullThetaSphere )
944 if ( (pTheta >= tolSTheta + kAngTolerance)
945 && (pTheta <= tolETheta - kAngTolerance) )
958 if ( !fFullThetaSphere )
960 if ( (pTheta >= tolSTheta + kAngTolerance)
961 && (pTheta <= tolETheta - kAngTolerance) )
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) ;
983 if ( !fFullPhiSphere && rhoi )
985 cosPsi = (xi*cosCPhi + yi*sinCPhi)/rhoi ;
987 if (cosPsi >= cosHDPhiOT)
989 if ( !fFullThetaSphere )
991 zi = p.
z() + sd*v.
z() ;
996 iTheta = std::atan2(rhoi,zi) ;
997 if ( (iTheta >= tolSTheta) && (iTheta<=tolETheta) )
1010 if ( !fFullThetaSphere )
1012 zi = p.
z() + sd*v.
z() ;
1017 iTheta = std::atan2(rhoi,zi) ;
1018 if ( (iTheta >= tolSTheta) && (iTheta <= tolETheta) )
1042 if ( !fFullPhiSphere )
1047 Comp = v.
x()*sinSPhi - v.
y()*cosSPhi ;
1051 Dist = p.
y()*cosSPhi - p.
x()*sinSPhi ;
1053 if (Dist < halfCarTolerance)
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)
1078 && ((yi*cosCPhi-xi*sinCPhi) <= 0) )
1084 if ( !fFullThetaSphere )
1086 iTheta = std::atan2(std::sqrt(rhoi2),zi) ;
1087 if ( (iTheta >= tolSTheta) && (iTheta <= tolETheta) )
1092 if ((yi*cosCPhi-xi*sinCPhi) <= 0)
1110 Comp = -( v.
x()*sinEPhi-v.
y()*cosEPhi ) ;
1114 Dist = -(p.
y()*cosEPhi-p.
x()*sinEPhi) ;
1115 if ( Dist < halfCarTolerance )
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)
1140 && ((yi*cosCPhi-xi*sinCPhi) >= 0) )
1146 if ( !fFullThetaSphere )
1148 iTheta = std::atan2(std::sqrt(rhoi2),zi) ;
1149 if ( (iTheta >= tolSTheta) && (iTheta <= tolETheta) )
1154 if ((yi*cosCPhi-xi*sinCPhi) >= 0)
1172 if ( !fFullThetaSphere )
1197 dist2STheta = rho2 - p.
z()*p.
z()*tanSTheta2 ;
1201 dist2STheta = kInfinity ;
1205 dist2ETheta=rho2-p.
z()*p.
z()*tanETheta2;
1209 dist2ETheta=kInfinity;
1211 if ( pTheta < tolSTheta )
1216 t1 = 1 - v.
z()*v.
z()*(1 + tanSTheta2) ;
1217 t2 = pDotV2d - p.
z()*v.
z()*tanSTheta2 ;
1221 c = dist2STheta/t1 ;
1228 zi = p.
z() + sd*v.
z();
1230 if ( (sd < 0) || (zi*(fSTheta - halfpi) > 0) )
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)
1243 && (zi*(fSTheta - halfpi) <= 0) )
1245 if ( !fFullPhiSphere && rhoi2 )
1247 cosPsi = (xi*cosCPhi + yi*sinCPhi)/std::sqrt(rhoi2) ;
1248 if (cosPsi >= cosHDPhiOT)
1267 t1 = 1 - v.
z()*v.
z()*(1 + tanETheta2) ;
1268 t2 = pDotV2d - p.
z()*v.
z()*tanETheta2 ;
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)
1290 && (zi*(eTheta - halfpi) <= 0) )
1292 if (!fFullPhiSphere && rhoi2)
1294 cosPsi = (xi*cosCPhi + yi*sinCPhi)/std::sqrt(rhoi2) ;
1295 if (cosPsi >= cosHDPhiOT)
1310 else if ( pTheta > tolETheta )
1316 t1 = 1 - v.
z()*v.
z()*(1 + tanETheta2) ;
1317 t2 = pDotV2d - p.
z()*v.
z()*tanETheta2 ;
1321 c = dist2ETheta/t1 ;
1328 zi = p.
z() + sd*v.
z();
1330 if ( (sd < 0) || (zi*(eTheta - halfpi) > 0) )
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)
1344 && (zi*(eTheta - halfpi) <= 0) )
1346 if (!fFullPhiSphere && rhoi2)
1348 cosPsi = (xi*cosCPhi + yi*sinCPhi)/std::sqrt(rhoi2) ;
1349 if (cosPsi >= cosHDPhiOT)
1368 t1 = 1 - v.
z()*v.
z()*(1 + tanSTheta2) ;
1369 t2 = pDotV2d - p.
z()*v.
z()*tanSTheta2 ;
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)
1391 && (zi*(fSTheta - halfpi) <= 0) )
1393 if (!fFullPhiSphere && rhoi2)
1395 cosPsi = (xi*cosCPhi + yi*sinCPhi)/std::sqrt(rhoi2) ;
1396 if (cosPsi >= cosHDPhiOT)
1411 else if ( (pTheta < tolSTheta + kAngTolerance)
1412 && (fSTheta > halfAngTolerance) )
1418 t2 = pDotV2d - p.
z()*v.
z()*tanSTheta2 ;
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) )
1423 if (!fFullPhiSphere && rho2)
1425 cosPsi = (p.
x()*cosCPhi + p.
y()*sinCPhi)/std::sqrt(rho2) ;
1426 if (cosPsi >= cosHDPhiIT)
1439 t1 = 1 - v.
z()*v.
z()*(1 + tanSTheta2) ;
1443 c = dist2STheta/t1 ;
1450 if ( (sd >= halfCarTolerance) && (sd < snxt) && (fSTheta < halfpi) )
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) )
1462 if ( !fFullPhiSphere && rhoi2 )
1464 cosPsi = (xi*cosCPhi + yi*sinCPhi)/std::sqrt(rhoi2) ;
1465 if ( cosPsi >= cosHDPhiOT )
1479 else if ((pTheta > tolETheta-kAngTolerance) && (eTheta < pi-kAngTolerance))
1486 t2 = pDotV2d - p.
z()*v.
z()*tanETheta2 ;
1488 if ( ((t2<0) && (eTheta < halfpi)
1489 && (tolIRMin2 < rad2) && (rad2 < tolIRMax2))
1490 || ((t2>=0) && (eTheta > halfpi)
1491 && (tolIRMin2 < rad2) && (rad2 < tolIRMax2))
1492 || ((v.
z()>0) && (eTheta == halfpi)
1493 && (tolIRMin2 < rad2) && (rad2 < tolIRMax2)) )
1495 if (!fFullPhiSphere && rho2)
1497 cosPsi = (p.
x()*cosCPhi + p.
y()*sinCPhi)/std::sqrt(rho2) ;
1498 if (cosPsi >= cosHDPhiIT)
1511 t1 = 1 - v.
z()*v.
z()*(1 + tanETheta2) ;
1515 c = dist2ETheta/t1 ;
1523 if ( (sd >= halfCarTolerance)
1524 && (sd < snxt) && (eTheta > halfpi) )
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)
1534 && (zi*(eTheta - halfpi) <= 0) )
1536 if (!fFullPhiSphere && rhoi2)
1538 cosPsi = (xi*cosCPhi + yi*sinCPhi)/std::sqrt(rhoi2) ;
1539 if (cosPsi >= cosHDPhiOT)
1558 t1 = 1 - v.
z()*v.
z()*(1 + tanSTheta2) ;
1559 t2 = pDotV2d - p.
z()*v.
z()*tanSTheta2 ;
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)
1581 && (zi*(fSTheta - halfpi) <= 0) )
1583 if (!fFullPhiSphere && rhoi2)
1585 cosPsi = (xi*cosCPhi + yi*sinCPhi)/std::sqrt(rhoi2) ;
1586 if (cosPsi >= cosHDPhiOT)
1599 t1 = 1 - v.
z()*v.
z()*(1 + tanETheta2) ;
1600 t2 = pDotV2d - p.
z()*v.
z()*tanETheta2 ;
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)
1622 && (zi*(eTheta - halfpi) <= 0) )
1624 if (!fFullPhiSphere && rhoi2)
1626 cosPsi = (xi*cosCPhi + yi*sinCPhi)/std::sqrt(rhoi2) ;
1627 if ( cosPsi >= cosHDPhiOT )
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)
1687 if (!fFullPhiSphere && rho)
1691 cosPsi=(p.
x()*cosCPhi+p.
y()*sinCPhi)/rho;
1692 if (cosPsi<cosHDPhi)
1696 if ((p.
y()*cosCPhi-p.
x()*sinCPhi)<=0)
1698 safePhi=std::fabs(p.
x()*sinSPhi-p.
y()*cosSPhi);
1702 safePhi=std::fabs(p.
x()*sinEPhi-p.
y()*cosEPhi);
1704 if (safePhi>safe) { safe=safePhi; }
1710 if ((rds!=0.0) && (!fFullThetaSphere))
1712 pTheta=std::acos(p.
z()/rds);
1713 if (pTheta<0) { pTheta+=pi; }
1714 dTheta1=fSTheta-pTheta;
1715 dTheta2=pTheta-eTheta;
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; }
1756 G4double sphi= kInfinity,stheta= kInfinity;
1757 ESide side=kNull,sidephi=kNull,sidetheta=kNull;
1759 const G4double halfRmaxTolerance = fRmaxTolerance*0.5;
1760 const G4double halfRminTolerance = fRminTolerance*0.5;
1761 const G4double Rmax_plus = fRmax + halfRmaxTolerance;
1762 const G4double Rmin_minus = (fRmin) ? fRmin-halfRminTolerance : 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) )
1806 c = rad2 - fRmax*fRmax;
1808 if (c < fRmaxTolerance*fRmax)
1819 d2 = pDotV3d*pDotV3d - c;
1821 if( (c >- fRmaxTolerance*fRmax)
1822 && ((pDotV3d >=0) || (d2 < 0)) )
1834 snxt = -pDotV3d+std::sqrt(d2);
1845 c = rad2 - fRmin*fRmin;
1846 d2 = pDotV3d*pDotV3d - c;
1848 if (c >- fRminTolerance*fRmin)
1850 if ( (c < fRminTolerance*fRmin)
1851 && (d2 >= fRminTolerance*fRmin) && (pDotV3d < 0) )
1853 if(calcNorm) { *validNorm =
false; }
1860 sd = -pDotV3d-std::sqrt(d2);
1875 if ( !fFullThetaSphere )
1902 if( std::fabs(tanSTheta) > 5./kAngTolerance )
1906 if ( std::fabs( p.
z() ) <= halfRmaxTolerance )
1915 stheta = -p.
z()/v.
z();
1916 sidetheta = kSTheta;
1921 t1 = 1-v.
z()*v.
z()*(1+tanSTheta2);
1922 t2 = pDotV2d-p.
z()*v.
z()*tanSTheta2;
1923 dist2STheta = rho2-p.
z()*p.
z()*tanSTheta2;
1925 distTheta = std::sqrt(rho2)-p.
z()*tanSTheta;
1927 if( std::fabs(t1) < halfAngTolerance )
1931 if(std::fabs(distTheta) < halfRmaxTolerance)
1933 if( (fSTheta < halfpi) && (p.
z() > 0.) )
1935 if( calcNorm ) { *validNorm =
false; }
1938 else if( (fSTheta > halfpi) && (p.
z() <= 0) )
1945 rhoSecTheta = std::sqrt(rho2*(1+tanSTheta2));
1949 std::sin(fSTheta) );
1956 stheta = -0.5*dist2STheta/t2;
1957 sidetheta = kSTheta;
1962 if( std::fabs(distTheta) < halfRmaxTolerance )
1964 if( (fSTheta > halfpi) && (t2 >= 0.) )
1971 rhoSecTheta = std::sqrt(rho2*(1+tanSTheta2));
1975 std::sin(fSTheta) );
1981 else if( (fSTheta < halfpi) && (t2 < 0.) && (p.
z() >=0.) )
1983 if( calcNorm ) { *validNorm =
false; }
1995 if( fSTheta > halfpi )
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.) )
2007 sidetheta = kSTheta;
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.) )
2022 sidetheta = kSTheta;
2031 if( std::fabs(tanETheta) > 5./kAngTolerance )
2035 if ( std::fabs( p.
z() ) <= halfRmaxTolerance )
2049 sidetheta = kETheta;
2055 t1 = 1-v.
z()*v.
z()*(1+tanETheta2);
2056 t2 = pDotV2d-p.
z()*v.
z()*tanETheta2;
2057 dist2ETheta = rho2-p.
z()*p.
z()*tanETheta2;
2059 distTheta = std::sqrt(rho2)-p.
z()*tanETheta;
2061 if( std::fabs(t1) < halfAngTolerance )
2065 if(std::fabs(distTheta) < halfRmaxTolerance)
2067 if( (eTheta > halfpi) && (p.
z() < 0.) )
2069 if( calcNorm ) { *validNorm =
false; }
2072 else if ( (eTheta < halfpi) && (p.
z() >= 0) )
2079 rhoSecTheta = std::sqrt(rho2*(1+tanETheta2));
2089 sd = -0.5*dist2ETheta/t2;
2094 sidetheta = kETheta;
2100 if ( std::fabs(distTheta) < halfRmaxTolerance )
2102 if( (eTheta < halfpi) && (t2 >= 0.) )
2109 rhoSecTheta = std::sqrt(rho2*(1+tanETheta2));
2118 else if ( (eTheta > halfpi)
2119 && (t2 < 0.) && (p.
z() <=0.) )
2121 if( calcNorm ) { *validNorm =
false; }
2128 if ( (d2 <halfRmaxTolerance) && (d2 > -halfRmaxTolerance) )
2136 if( eTheta < halfpi )
2140 if( ((std::fabs(sd) < halfRmaxTolerance) && (t2 < 0.))
2145 if( sd > halfRmaxTolerance )
2150 sidetheta = kETheta;
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 ) )
2170 sidetheta = kETheta;
2183 if ( !fFullPhiSphere )
2185 if ( p.
x() || p.
y() )
2189 pDistS=p.
x()*sinSPhi-p.
y()*cosSPhi;
2190 pDistE=-p.
x()*sinEPhi+p.
y()*cosEPhi;
2194 compS = -sinSPhi*v.
x()+cosSPhi*v.
y() ;
2195 compE = sinEPhi*v.
x()-cosEPhi*v.
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());
2214 if ( ( (fSPhi-halfAngTolerance) <= vphi)
2215 && ( (ePhi+halfAngTolerance) >= vphi) )
2220 else if ( ( yi*cosCPhi - xi*sinCPhi ) >= 0 )
2227 if ( pDistS > -halfCarTolerance) { sphi = 0; }
2230 else { sphi = kInfinity; }
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()) ;
2249 if( !((fSPhi-halfAngTolerance <= vphi)
2250 &&(fSPhi+fDPhi+halfAngTolerance >= vphi)) )
2253 if ( pDistE <= -halfCarTolerance ) { sphi = sphi2; }
2254 else { sphi = 0.0; }
2257 else if ((yi*cosCPhi-xi*sinCPhi)>=0)
2260 if ( pDistE <= -halfCarTolerance )
2272 else if ((pDistS >= 0) && (pDistE >= 0))
2274 if ( pDistS <= pDistE )
2284 if ( (compS < 0) && (compE < 0) ) { sphi = 0; }
2285 else { sphi = kInfinity; }
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());
2315 if ( ( (fSPhi-halfAngTolerance) <= vphi)
2316 && ( (ePhi+halfAngTolerance) >= vphi) )
2321 else if ( ( yi*cosCPhi - xi*sinCPhi ) <= 0 )
2328 if ( pDistE > -halfCarTolerance ) { sphi = 0.; }
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());
2354 if ( ( (fSPhi-halfAngTolerance) <= vphi)
2355 && ( (ePhi+halfAngTolerance) >= vphi) )
2360 else if ( ( yi*cosCPhi - xi*sinCPhi) <= 0 )
2369 else sphi=kInfinity;
2388 xi=p.
x()+sphi*v.
x();
2389 yi=p.
y()+sphi*v.
y();
2396 vphi = std::atan2(v.
y(),v.
x()) ;
2398 if ( ( (fSPhi-halfAngTolerance) <= vphi)
2399 && ( (ePhi+halfAngTolerance) >= vphi) )
2404 else if ( ( yi*cosCPhi - xi*sinCPhi ) >= 0 )
2411 if ( pDistS > -halfCarTolerance ) { sphi = 0; }
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()) ;
2437 if ( ( (fSPhi-halfAngTolerance) <= vphi)
2438 && ( (ePhi+halfAngTolerance) >= vphi) )
2443 else if ( ( yi*cosCPhi - xi*sinCPhi ) >= 0 )
2470 if ( v.
x() || v.
y() )
2472 vphi = std::atan2(v.
y(),v.
x()) ;
2473 if ((fSPhi-halfAngTolerance < vphi) && (vphi < ePhi+halfAngTolerance))
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; }
2535 if( fSTheta == halfpi )
2540 else if ( fSTheta > halfpi )
2542 xi = p.
x() + snxt*v.
x();
2543 yi = p.
y() + snxt*v.
y();
2547 rhoSecTheta = std::sqrt(rho2*(1+tanSTheta2));
2549 -tanSTheta/std::sqrt(1+tanSTheta2));
2557 else { *validNorm=
false; }
2561 if( eTheta == halfpi )
2566 else if ( eTheta < halfpi )
2568 xi=p.
x()+snxt*v.
x();
2569 yi=p.
y()+snxt*v.
y();
2573 rhoSecTheta = std::sqrt(rho2*(1+tanETheta2));
2575 -tanETheta/std::sqrt(1+tanETheta2) );
2583 else { *validNorm=
false; }
2589 std::ostringstream message;
2590 G4int oldprc = message.precision(16);
2591 message <<
"Undefined side for valid surface normal to solid."
2594 <<
"p.x() = " << p.
x()/mm <<
" mm" <<
G4endl
2595 <<
"p.y() = " << p.
y()/mm <<
" mm" <<
G4endl
2598 <<
"v.x() = " << v.
x() <<
G4endl
2599 <<
"v.y() = " << v.
y() <<
G4endl
2602 <<
"snxt = " << snxt/mm <<
" mm" <<
G4endl;
2603 message.precision(oldprc);
2609 if (snxt == kInfinity)
2613 std::ostringstream message;
2614 G4int oldprc = message.precision(16);
2615 message <<
"Logic error: snxt = kInfinity ???" <<
G4endl
2617 <<
"p.x() = " << p.
x()/mm <<
" mm" <<
G4endl
2618 <<
"p.y() = " << p.
y()/mm <<
" mm" <<
G4endl
2620 <<
"Rp = "<< std::sqrt( p.
x()*p.
x()+p.
y()*p.
y()+p.
z()*p.
z() )/mm
2623 <<
"v.x() = " << v.
x() <<
G4endl
2624 <<
"v.y() = " << v.
y() <<
G4endl
2627 <<
"snxt = " << snxt/mm <<
" mm" <<
G4endl;
2628 message.precision(oldprc);
2642 G4double safe=0.0,safeRMin,safeRMax,safePhi,safeTheta;
2644 G4double pTheta,dTheta1 = kInfinity,dTheta2 = kInfinity;
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 );
2677 if ( !fFullPhiSphere )
2681 if ((p.
y()*cosCPhi-p.
x()*sinCPhi)<=0)
2683 safePhi=-(p.
x()*sinSPhi-p.
y()*cosSPhi);
2687 safePhi=(p.
x()*sinEPhi-p.
y()*cosEPhi);
2697 safe= std::min(safe, safePhi);
2702 if ( !fFullThetaSphere )
2706 pTheta=std::acos(p.
z()/rds);
2707 if (pTheta<0) { pTheta+=pi; }
2709 { dTheta1=pTheta-fSTheta;}
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;
2780 height1 = (fRmax-fRmin)*cosSTheta;
2781 height2 = (fRmax-fRmin)*cosETheta;
2782 slant1 = std::sqrt(
sqr((fRmax - fRmin)*sinSTheta) + height1*height1);
2783 slant2 = std::sqrt(
sqr((fRmax - fRmin)*sinETheta) + height2*height2);
2786 aOne = fRmax*fRmax*fDPhi*(cosSTheta-cosETheta);
2787 aTwo = fRmin*fRmin*fDPhi*(cosSTheta-cosETheta);
2788 aThr = fDPhi*((fRmax + fRmin)*sinSTheta)*slant1;
2789 aFou = fDPhi*((fRmax + fRmin)*sinETheta)*slant2;
2790 aFiv = 0.5*fDTheta*(fRmax*fRmax-fRmin*fRmin);
2792 phi = G4RandFlat::shoot(fSPhi, ePhi);
2793 cosphi = std::cos(phi);
2794 sinphi = std::sin(phi);
2795 costheta = G4RandFlat::shoot(cosETheta,cosSTheta);
2796 sintheta = std::sqrt(1.-
sqr(costheta));
2798 if(fFullPhiSphere) { aFiv = 0; }
2799 if(fSTheta == 0) { aThr=0; }
2800 if(eTheta == pi) { aFou = 0; }
2801 if(fSTheta == halfpi) { aThr = pi*(fRmax*fRmax-fRmin*fRmin); }
2802 if(eTheta == halfpi) { aFou = pi*(fRmax*fRmax-fRmin*fRmin); }
2804 chose = G4RandFlat::shoot(0.,aOne+aTwo+aThr+aFou+2.*aFiv);
2805 if( (chose>=0.) && (chose<aOne) )
2808 fRmax*sintheta*sinphi, fRmax*costheta);
2810 else if( (chose>=aOne) && (chose<aOne+aTwo) )
2813 fRmin*sintheta*sinphi, fRmin*costheta);
2815 else if( (chose>=aOne+aTwo) && (chose<aOne+aTwo+aThr) )
2817 if (fSTheta != halfpi)
2819 zRand = G4RandFlat::shoot(fRmin*cosSTheta,fRmax*cosSTheta);
2821 tanSTheta*zRand*sinphi,zRand);
2828 else if( (chose>=aOne+aTwo+aThr) && (chose<aOne+aTwo+aThr+aFou) )
2830 if(eTheta != halfpi)
2832 zRand = G4RandFlat::shoot(fRmin*cosETheta, fRmax*cosETheta);
2834 tanETheta*zRand*sinphi,zRand);
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);
2865 fSurfaceArea = fDPhi*(rsq+Rsq)*(cosSTheta - cosETheta);
2872 G4double acos1=std::acos( std::pow(sinSTheta,2) * std::cos(fDPhi)
2873 + std::pow(cosSTheta,2));
2885 G4double acos2=std::acos( std::pow(sinETheta,2) * std::cos(fDPhi)
2886 + std::pow(cosETheta,2));
2906 return G4VisExtent(-fRmax, fRmax,-fRmax, fRmax,-fRmax, fRmax );
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
CLHEP::Hep3Vector G4ThreeVector
G4GLOB_DLL std::ostream G4cout
void set(double x, double y, double z)
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimits, const G4Transform3D &pTransform3D, G4double &pMin, G4double &pMax) const
G4double GetRadiusInRing(G4double rmin, G4double rmax) const
G4CSGSolid & operator=(const G4CSGSolid &rhs)
G4double GetRadialTolerance() const
static G4GeometryTolerance * GetInstance()
G4double GetAngularTolerance() const
G4ThreeVector GetPointOnSurface() const
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
G4Sphere(const G4String &pName, G4double pRmin, G4double pRmax, G4double pSPhi, G4double pDPhi, G4double pSTheta, G4double pDTheta)
G4double GetSinStartTheta() const
G4double GetCosStartPhi() const
std::ostream & StreamInfo(std::ostream &os) const
G4double GetDeltaPhiAngle() const
G4VisExtent GetExtent() const
G4double GetCosEndTheta() const
G4GeometryType GetEntityType() const
G4Polyhedron * CreatePolyhedron() const
G4double GetInnerRadius() const
EInside Inside(const G4ThreeVector &p) const
G4double GetOuterRadius() const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
G4double GetCosEndPhi() const
G4double GetSinEndTheta() const
G4double GetDeltaThetaAngle() const
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
G4double GetSinEndPhi() const
void DescribeYourselfTo(G4VGraphicsScene &scene) const
G4double GetSinStartPhi() const
G4Sphere & operator=(const G4Sphere &rhs)
G4double GetSurfaceArea()
G4double GetStartThetaAngle() const
G4double GetCosStartTheta() const
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const
virtual void AddSolid(const G4Box &)=0
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const