39 #if !defined(G4GEOM_USE_UCONS)
55 using namespace CLHEP;
77 :
G4CSGSolid(pName), fRmin1(pRmin1), fRmin2(pRmin2),
78 fRmax1(pRmax1), fRmax2(pRmax2), fDz(pDz), fSPhi(0.), fDPhi(0.)
92 message <<
"Invalid Z half-length for Solid: " <<
GetName() <<
G4endl
100 if (((pRmin1>=pRmax1) || (pRmin2>=pRmax2) || (pRmin1<0)) && (pRmin2<0))
103 message <<
"Invalid values of radii for Solid: " <<
GetName() <<
G4endl
104 <<
" pRmin1 = " << pRmin1 <<
", pRmin2 = " << pRmin2
105 <<
", pRmax1 = " << pRmax1 <<
", pRmax2 = " << pRmax2;
123 :
G4CSGSolid(a), kRadTolerance(0.), kAngTolerance(0.),
124 fRmin1(0.), fRmin2(0.), fRmax1(0.), fRmax2(0.), fDz(0.),
125 fSPhi(0.), fDPhi(0.), sinCPhi(0.), cosCPhi(0.), cosHDPhi(0.),
126 cosHDPhiOT(0.), cosHDPhiIT(0.), sinSPhi(0.), cosSPhi(0.),
127 sinEPhi(0.), cosEPhi(0.),
128 halfCarTolerance(0.), halfRadTolerance(0.), halfAngTolerance(0.)
145 :
G4CSGSolid(rhs), kRadTolerance(rhs.kRadTolerance),
146 kAngTolerance(rhs.kAngTolerance), fRmin1(rhs.fRmin1), fRmin2(rhs.fRmin2),
147 fRmax1(rhs.fRmax1), fRmax2(rhs.fRmax2), fDz(rhs.fDz), fSPhi(rhs.fSPhi),
148 fDPhi(rhs.fDPhi), sinCPhi(rhs.sinCPhi), cosCPhi(rhs.cosCPhi),
149 cosHDPhi(rhs.cosHDPhi), cosHDPhiOT(rhs.cosHDPhiOT),
150 cosHDPhiIT(rhs.cosHDPhiIT), sinSPhi(rhs.sinSPhi), cosSPhi(rhs.cosSPhi),
151 sinEPhi(rhs.sinEPhi), cosEPhi(rhs.cosEPhi), fPhiFullCone(rhs.fPhiFullCone),
152 halfCarTolerance(rhs.halfCarTolerance),
153 halfRadTolerance(rhs.halfRadTolerance),
154 halfAngTolerance(rhs.halfAngTolerance)
166 if (
this == &rhs) {
return *
this; }
204 r2 = p.
x()*p.
x() + p.
y()*p.
y() ;
211 if ( tolRMin < 0 ) { tolRMin = 0; }
214 if ( (r2<tolRMin*tolRMin) || (r2>tolRMax*tolRMax) ) {
return in =
kOutside; }
217 else { tolRMin = 0.0; }
222 if ( (r2 < tolRMin*tolRMin) || (r2 >= tolRMax*tolRMax) ) { in =
kSurface; }
226 pPhi = std::atan2(p.
y(),p.
x()) ;
276 pMin.
set(vmin.
x(),vmin.
y(),-
dz);
277 pMax.
set(vmax.
x(),vmax.
y(),
dz);
281 pMin.
set(-rmax,-rmax,-dz);
282 pMax.
set( rmax, rmax, dz);
287 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
290 message <<
"Bad bounding box (min >= max) for solid: "
292 <<
"\npMin = " << pMin
293 <<
"\npMax = " <<
pMax;
294 G4Exception(
"G4Cons::BoundingLimits()",
"GeomMgt0001",
319 if (
true)
return bbox.
CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
323 return exist = (pMin <
pMax) ?
true :
false;
336 const G4int NSTEPS = 24;
338 G4int ksteps = (dphi <= astep) ? 1 : (
G4int)((dphi-
deg)/astep) + 1;
341 G4double sinHalf = std::sin(0.5*ang);
342 G4double cosHalf = std::cos(0.5*ang);
343 G4double sinStep = 2.*sinHalf*cosHalf;
344 G4double cosStep = 1. - 2.*sinHalf*sinHalf;
350 if (rmin1 == 0 && rmin2 == 0 && dphi ==
twopi)
358 baseA[
k].set(rext1*cosCur,rext1*sinCur,-dz);
359 baseB[
k].set(rext2*cosCur,rext2*sinCur, dz);
362 sinCur = sinCur*cosStep + cosCur*sinStep;
363 cosCur = cosCur*cosStep - sinTmp*sinStep;
365 std::vector<const G4ThreeVectorList *> polygons(2);
366 polygons[0] = &baseA;
367 polygons[1] = &baseB;
377 G4double sinCur = sinStart*cosHalf + cosStart*sinHalf;
378 G4double cosCur = cosStart*cosHalf - sinStart*sinHalf;
382 for (
G4int k=0;
k<ksteps+2; ++
k) pols[
k].resize(4);
383 pols[0][0].set(rmin2*cosStart,rmin2*sinStart, dz);
384 pols[0][1].set(rmin1*cosStart,rmin1*sinStart,-dz);
385 pols[0][2].set(rmax1*cosStart,rmax1*sinStart,-dz);
386 pols[0][3].set(rmax2*cosStart,rmax2*sinStart, dz);
389 pols[
k][0].set(rmin2*cosCur,rmin2*sinCur, dz);
390 pols[
k][1].set(rmin1*cosCur,rmin1*sinCur,-dz);
391 pols[
k][2].set(rext1*cosCur,rext1*sinCur,-dz);
392 pols[
k][3].set(rext2*cosCur,rext2*sinCur, dz);
395 sinCur = sinCur*cosStep + cosCur*sinStep;
396 cosCur = cosCur*cosStep - sinTmp*sinStep;
398 pols[ksteps+1][0].set(rmin2*cosEnd,rmin2*sinEnd, dz);
399 pols[ksteps+1][1].set(rmin1*cosEnd,rmin1*sinEnd,-dz);
400 pols[ksteps+1][2].set(rmax1*cosEnd,rmax1*sinEnd,-dz);
401 pols[ksteps+1][3].set(rmax2*cosEnd,rmax2*sinEnd, dz);
404 std::vector<const G4ThreeVectorList *> polygons;
405 polygons.resize(ksteps+2);
406 for (
G4int k=0;
k<ksteps+2; ++
k) polygons[
k] = &pols[
k];
421 G4int noSurfaces = 0;
425 G4double tanRMin, secRMin, pRMin, widRMin;
426 G4double tanRMax, secRMax, pRMax, widRMax;
431 distZ = std::fabs(std::fabs(p.
z()) -
fDz);
432 rho = std::sqrt(p.
x()*p.
x() + p.
y()*p.
y());
435 secRMin = std::sqrt(1 + tanRMin*tanRMin);
436 pRMin = rho - p.
z()*tanRMin;
438 distRMin = std::fabs(pRMin - widRMin)/secRMin;
441 secRMax = std::sqrt(1+tanRMax*tanRMax);
442 pRMax = rho - p.
z()*tanRMax;
444 distRMax = std::fabs(pRMax - widRMax)/secRMax;
450 pPhi = std::atan2(p.
y(),p.
x());
455 distSPhi = std::fabs( pPhi -
fSPhi );
468 nR =
G4ThreeVector(p.
x()/rho/secRMax, p.
y()/rho/secRMax, -tanRMax/secRMax);
471 nr =
G4ThreeVector(-p.
x()/rho/secRMin,-p.
y()/rho/secRMin,tanRMin/secRMin);
501 if ( p.
z() >= 0.) { sumnorm += nZ; }
502 else { sumnorm -= nZ; }
504 if ( noSurfaces == 0 )
507 G4Exception(
"G4Cons::SurfaceNormal(p)",
"GeomSolids1002",
512 else if ( noSurfaces == 1 ) { norm = sumnorm; }
513 else { norm = sumnorm.
unit(); }
528 G4double distZ, distRMin, distRMax, distSPhi, distEPhi, distMin ;
529 G4double tanRMin, secRMin, pRMin, widRMin ;
530 G4double tanRMax, secRMax, pRMax, widRMax ;
532 distZ = std::fabs(std::fabs(p.
z()) -
fDz) ;
533 rho = std::sqrt(p.
x()*p.
x() + p.
y()*p.
y()) ;
536 secRMin = std::sqrt(1 + tanRMin*tanRMin) ;
537 pRMin = rho - p.
z()*tanRMin ;
539 distRMin = std::fabs(pRMin - widRMin)/secRMin ;
542 secRMax = std::sqrt(1+tanRMax*tanRMax) ;
543 pRMax = rho - p.
z()*tanRMax ;
545 distRMax = std::fabs(pRMax - widRMax)/secRMax ;
547 if (distRMin < distRMax)
549 if (distZ < distRMin)
562 if (distZ < distRMax)
575 phi = std::atan2(p.
y(),p.
x()) ;
577 if (phi < 0) { phi +=
twopi; }
580 else { distSPhi = std::fabs(phi -
fSPhi)*rho; }
582 distEPhi = std::fabs(phi -
fSPhi -
fDPhi)*rho ;
586 if (distSPhi < distEPhi)
588 if (distSPhi < distMin) { side =
kNSPhi; }
592 if (distEPhi < distMin) { side =
kNEPhi; }
630 "Undefined side for valid surface normal to solid.");
667 G4double tanRMax,secRMax,rMaxAv,rMaxOAv ;
668 G4double tanRMin,secRMin,rMinAv,rMinOAv ;
671 G4double tolORMin,tolORMin2,tolIRMin,tolIRMin2 ;
672 G4double tolORMax2,tolIRMax,tolIRMax2 ;
675 G4double Dist,sd,xi,yi,zi,ri=0.,risec,rhoi2,cosPsi ;
686 secRMin = std::sqrt(1.0 + tanRMin*tanRMin) ;
698 secRMax = std::sqrt(1.0 + tanRMax*tanRMax) ;
707 if (std::fabs(p.
z()) >= tolIDz)
709 if ( p.
z()*v.
z() < 0 )
711 sd = (std::fabs(p.
z()) -
fDz)/std::fabs(v.
z()) ;
713 if( sd < 0.0 ) { sd = 0.0; }
715 xi = p.
x() + sd*v.
x() ;
716 yi = p.
y() + sd*v.
y() ;
717 rhoi2 = xi*xi + yi*yi ;
724 tolORMin =
fRmin1 - halfRadTolerance*secRMin ;
725 tolIRMin =
fRmin1 + halfRadTolerance*secRMin ;
726 tolIRMax =
fRmax1 - halfRadTolerance*secRMin ;
732 tolORMin =
fRmin2 - halfRadTolerance*secRMin ;
733 tolIRMin =
fRmin2 + halfRadTolerance*secRMin ;
734 tolIRMax =
fRmax2 - halfRadTolerance*secRMin ;
741 tolIRMin2 = tolIRMin*tolIRMin ;
748 if ( tolIRMax > 0 ) { tolIRMax2 = tolIRMax*tolIRMax; }
749 else { tolIRMax2 = 0.0; }
751 if ( (tolIRMin2 <= rhoi2) && (rhoi2 <= tolIRMax2) )
792 t1 = 1.0 - v.
z()*v.
z() ;
793 t2 = p.
x()*v.
x() + p.
y()*v.
y() ;
794 t3 = p.
x()*p.
x() + p.
y()*p.
y() ;
795 rin = tanRMin*p.
z() + rMinAv ;
796 rout = tanRMax*p.
z() + rMaxAv ;
801 nt1 = t1 - (tanRMax*v.
z())*(tanRMax*v.
z()) ;
802 nt2 = t2 - tanRMax*v.
z()*rout ;
803 nt3 = t3 - rout*rout ;
819 if ((rout < 0) && (nt3 <= 0))
824 if (b>0) { sd = c/(-b-std::sqrt(d)); }
825 else { sd = -b + std::sqrt(d); }
829 if ((b <= 0) && (c >= 0))
831 sd=c/(-b+std::sqrt(d));
837 sd = -b + std::sqrt(d) ;
838 if((sd<0) & (sd>-halfRadTolerance)) sd=0;
850 G4double fTerm = sd-std::fmod(sd,dRmax);
853 zi = p.
z() + sd*v.
z() ;
855 if (std::fabs(zi) <= tolODz)
862 xi = p.
x() + sd*v.
x() ;
863 yi = p.
y() + sd*v.
y() ;
864 ri = rMaxAv + zi*tanRMax ;
878 if ( ( t3 > (rin + halfRadTolerance*secRMin)*
879 (rin + halfRadTolerance*secRMin) )
880 && (nt2 < 0) && (d >= 0) && (std::fabs(p.
z()) <= tolIDz) )
887 risec = std::sqrt(xi*xi + yi*yi)*secRMax ;
894 if ( Normal.
dot(v) <= 0 ) {
return 0.0; }
899 if ( Normal.
dot(v) <= 0 ) {
return 0.0; }
913 zi = p.
z() + sd*v.
z() ;
915 if ((std::fabs(zi) <= tolODz) && (nt2 < 0))
922 xi = p.
x() + sd*v.
x() ;
923 yi = p.
y() + sd*v.
y() ;
924 ri = rMaxAv + zi*tanRMax ;
949 nt1 = t1 - (tanRMin*v.
z())*(tanRMin*v.
z()) ;
950 nt2 = t2 - tanRMin*v.
z()*rin ;
965 if(b>0){sd = c/( -b-std::sqrt(d));}
966 else {sd = -b + std::sqrt(d) ;}
972 G4double fTerm = sd-std::fmod(sd,dRmax);
975 zi = p.
z() + sd*v.
z() ;
977 if ( std::fabs(zi) <= tolODz )
981 xi = p.
x() + sd*v.
x() ;
982 yi = p.
y() + sd*v.
y() ;
983 ri = rMinAv + zi*tanRMin ;
988 if ( sd > halfRadTolerance ) { snxt=sd; }
993 risec = std::sqrt(xi*xi + yi*yi)*secRMin ;
995 if ( Normal.
dot(v) <= 0 ) { snxt = sd; }
1001 if ( sd > halfRadTolerance ) {
return sd; }
1006 xi = p.
x() + sd*v.
x() ;
1007 yi = p.
y() + sd*v.
y() ;
1008 risec = std::sqrt(xi*xi + yi*yi)*secRMin ;
1009 Normal =
G4ThreeVector(-xi/risec,-yi/risec,tanRMin/secRMin) ;
1010 if ( Normal.
dot(v) <= 0 ) {
return sd; }
1030 if (b>0) { sd = c/(-b-std::sqrt(d)); }
1031 else { sd = -b + std::sqrt(d); }
1032 zi = p.
z() + sd*v.
z() ;
1033 ri = rMinAv + zi*tanRMin ;
1037 if ( (sd >= 0) && (std::fabs(zi) <= tolODz) )
1041 G4double fTerm = sd-std::fmod(sd,dRmax);
1046 xi = p.
x() + sd*v.
x() ;
1047 yi = p.
y() + sd*v.
y() ;
1052 if ( sd > halfRadTolerance ) { snxt=sd; }
1057 risec = std::sqrt(xi*xi + yi*yi)*secRMin ;
1058 Normal =
G4ThreeVector(-xi/risec,-yi/risec,tanRMin/secRMin);
1059 if ( Normal.
dot(v) <= 0 ) { snxt = sd; }
1065 if( sd > halfRadTolerance ) {
return sd; }
1070 xi = p.
x() + sd*v.
x() ;
1071 yi = p.
y() + sd*v.
y() ;
1072 risec = std::sqrt(xi*xi + yi*yi)*secRMin ;
1073 Normal =
G4ThreeVector(-xi/risec,-yi/risec,tanRMin/secRMin) ;
1074 if ( Normal.
dot(v) <= 0 ) {
return sd; }
1081 if (b>0) { sd = -b - std::sqrt(d); }
1082 else { sd = c/(-b+std::sqrt(d)); }
1083 zi = p.
z() + sd*v.
z() ;
1084 ri = rMinAv + zi*tanRMin ;
1086 if ( (sd >= 0) && (ri > 0) && (std::fabs(zi) <= tolODz) )
1090 G4double fTerm = sd-std::fmod(sd,dRmax);
1095 xi = p.
x() + sd*v.
x() ;
1096 yi = p.
y() + sd*v.
y() ;
1101 if ( sd > halfRadTolerance ) { snxt=sd; }
1106 risec = std::sqrt(xi*xi + yi*yi)*secRMin ;
1107 Normal =
G4ThreeVector(-xi/risec,-yi/risec,tanRMin/secRMin);
1108 if ( Normal.
dot(v) <= 0 ) { snxt = sd; }
1114 if ( sd > halfRadTolerance ) {
return sd; }
1119 xi = p.
x() + sd*v.
x() ;
1120 yi = p.
y() + sd*v.
y() ;
1121 risec = std::sqrt(xi*xi + yi*yi)*secRMin ;
1122 Normal =
G4ThreeVector(-xi/risec,-yi/risec,tanRMin/secRMin) ;
1123 if ( Normal.
dot(v) <= 0 ) {
return sd; }
1137 if ( std::fabs(p.
z()) <= tolODz )
1149 else {
return 0.0; }
1162 if (b>0) { sd = -b - std::sqrt(d); }
1163 else { sd = c/(-b+std::sqrt(d)); }
1164 zi = p.
z() + sd*v.
z() ;
1165 ri = rMinAv + zi*tanRMin ;
1169 if (b>0) { sd = c/(-b-std::sqrt(d)); }
1170 else { sd = -b + std::sqrt(d); }
1172 zi = p.
z() + sd*v.
z() ;
1174 if ( (sd >= 0) && (std::fabs(zi) <= tolODz) )
1178 G4double fTerm = sd-std::fmod(sd,dRmax);
1183 xi = p.
x() + sd*v.
x() ;
1184 yi = p.
y() + sd*v.
y() ;
1185 ri = rMinAv + zi*tanRMin ;
1205 if (b>0) { sd = c/(-b-std::sqrt(d)); }
1206 else { sd = -b + std::sqrt(d) ; }
1207 zi = p.
z() + sd*v.
z() ;
1209 if ( (sd >= 0) && (std::fabs(zi) <= tolODz) )
1213 G4double fTerm = sd-std::fmod(sd,dRmax);
1218 xi = p.
x() + sd*v.
x();
1219 yi = p.
y() + sd*v.
y();
1220 ri = rMinAv + zi*tanRMin ;
1252 if (Dist < halfCarTolerance)
1258 if ( sd < 0 ) { sd = 0.0; }
1260 zi = p.
z() + sd*v.
z() ;
1262 if ( std::fabs(zi) <= tolODz )
1264 xi = p.
x() + sd*v.
x() ;
1265 yi = p.
y() + sd*v.
y() ;
1266 rhoi2 = xi*xi + yi*yi ;
1267 tolORMin2 = (rMinOAv + zi*tanRMin)*(rMinOAv + zi*tanRMin) ;
1268 tolORMax2 = (rMaxOAv + zi*tanRMax)*(rMaxOAv + zi*tanRMax) ;
1270 if ( (rhoi2 >= tolORMin2) && (rhoi2 <= tolORMax2) )
1289 if (Dist < halfCarTolerance)
1295 if ( sd < 0 ) { sd = 0.0; }
1297 zi = p.
z() + sd*v.
z() ;
1299 if (std::fabs(zi) <= tolODz)
1301 xi = p.
x() + sd*v.
x() ;
1302 yi = p.
y() + sd*v.
y() ;
1303 rhoi2 = xi*xi + yi*yi ;
1304 tolORMin2 = (rMinOAv + zi*tanRMin)*(rMinOAv + zi*tanRMin) ;
1305 tolORMax2 = (rMaxOAv + zi*tanRMax)*(rMaxOAv + zi*tanRMax) ;
1307 if ( (rhoi2 >= tolORMin2) && (rhoi2 <= tolORMax2) )
1319 if (snxt < halfCarTolerance) { snxt = 0.; }
1333 G4double safe=0.0, rho, safeR1, safeR2, safeZ, safePhi, cosPsi ;
1337 rho = std::sqrt(p.
x()*p.
x() + p.
y()*p.
y()) ;
1338 safeZ = std::fabs(p.
z()) -
fDz ;
1343 secRMin = std::sqrt(1.0 + tanRMin*tanRMin) ;
1345 safeR1 = (pRMin - rho)/secRMin ;
1348 secRMax = std::sqrt(1.0 + tanRMax*tanRMax) ;
1350 safeR2 = (rho - pRMax)/secRMax ;
1352 if ( safeR1 > safeR2) { safe = safeR1; }
1353 else { safe = safeR2; }
1358 secRMax = std::sqrt(1.0 + tanRMax*tanRMax) ;
1360 safe = (rho - pRMax)/secRMax ;
1362 if ( safeZ > safe ) { safe = safeZ; }
1380 if ( safePhi > safe ) { safe = safePhi; }
1383 if ( safe < 0.0 ) { safe = 0.0; }
1403 G4double tanRMax, secRMax, rMaxAv ;
1404 G4double tanRMin, secRMin, rMinAv ;
1416 G4double pDistS, compS, pDistE, compE, sphi2, xi, yi, risec, vphi ;
1423 pdist =
fDz - p.
z() ;
1427 snxt = pdist/v.
z() ;
1440 else if ( v.
z() < 0.0 )
1442 pdist =
fDz + p.
z() ;
1446 snxt = -pdist/v.
z() ;
1483 secRMax = std::sqrt(1.0 + tanRMax*tanRMax) ;
1487 t1 = 1.0 - v.
z()*v.
z() ;
1488 t2 = p.
x()*v.
x() + p.
y()*v.
y() ;
1489 t3 = p.
x()*p.
x() + p.
y()*p.
y() ;
1490 rout = tanRMax*p.
z() + rMaxAv ;
1492 nt1 = t1 - (tanRMax*v.
z())*(tanRMax*v.
z()) ;
1493 nt2 = t2 - tanRMax*v.
z()*rout ;
1494 nt3 = t3 - rout*rout ;
1498 deltaRoi2 = snxt*snxt*t1 + 2*snxt*t2 + t3
1501 else if (v.
z() < 0.0)
1503 deltaRoi2 = snxt*snxt*t1 + 2*snxt*t2 + t3
1511 if ( nt1 && (deltaRoi2 > 0.0) )
1528 risec = std::sqrt(t3)*secRMax ;
1537 if (b>0) { srd = -b - std::sqrt(d); }
1538 else { srd = c/(-b+std::sqrt(d)) ; }
1540 zi = p.
z() + srd*v.
z() ;
1541 ri = tanRMax*zi + rMaxAv ;
1556 if (b>0) { sr2 = c/(-b-std::sqrt(d)); }
1557 else { sr2 = -b + std::sqrt(d); }
1558 zi = p.
z() + sr2*v.
z() ;
1559 ri = tanRMax*zi + rMaxAv ;
1588 risec = std::sqrt(t3)*secRMax;
1595 else if ( nt2 && (deltaRoi2 > 0.0) )
1601 risec = std::sqrt(t3)*secRMax;
1628 xi = p.
x() + slentol*v.
x();
1629 yi = p.
y() + slentol*v.
y();
1630 risec = std::sqrt(xi*xi + yi*yi)*secRMax;
1633 if ( Normal.
dot(v) > 0 )
1637 *n = Normal.
unit() ;
1653 nt1 = t1 - (tanRMin*v.
z())*(tanRMin*v.
z()) ;
1657 secRMin = std::sqrt(1.0 + tanRMin*tanRMin) ;
1659 rin = tanRMin*p.
z() + rMinAv ;
1660 nt2 = t2 - tanRMin*v.
z()*rin ;
1661 nt3 = t3 - rin*rin ;
1678 if (calcNorm) { *validNorm =
false; }
1684 if (b>0) { sr2 = -b - std::sqrt(d); }
1685 else { sr2 = c/(-b+std::sqrt(d)); }
1686 zi = p.
z() + sr2*v.
z() ;
1687 ri = tanRMin*zi + rMinAv ;
1699 if (b>0) { sr3 = c/(-b-std::sqrt(d)); }
1700 else { sr3 = -b + std::sqrt(d) ; }
1709 zi = p.
z() + sr3*v.
z() ;
1710 ri = tanRMin*zi + rMinAv ;
1748 xi = p.
x() + slentol*v.
x() ;
1749 yi = p.
y() + slentol*v.
y() ;
1750 if( sidetol==
kRMax )
1752 risec = std::sqrt(xi*xi + yi*yi)*secRMax ;
1753 Normal =
G4ThreeVector(xi/risec,yi/risec,-tanRMax/secRMax) ;
1757 risec = std::sqrt(xi*xi + yi*yi)*secRMin ;
1758 Normal =
G4ThreeVector(-xi/risec,-yi/risec,tanRMin/secRMin) ;
1760 if( Normal.
dot(v) > 0 )
1766 *n = Normal.
unit() ;
1793 vphi = std::atan2(v.
y(),v.
x()) ;
1798 if ( p.
x() || p.
y() )
1820 sphi = pDistS/compS ;
1823 xi = p.
x() + sphi*v.
x() ;
1824 yi = p.
y() + sphi*v.
y() ;
1865 sphi2 = pDistE/compE ;
1871 xi = p.
x() + sphi2*v.
x() ;
1872 yi = p.
y() + sphi2*v.
y() ;
1886 else { sphi = 0.0; }
1896 else { sphi = 0.0; }
1938 xi = p.
x() + snxt*v.
x() ;
1939 yi = p.
y() + snxt*v.
y() ;
1940 risec = std::sqrt(xi*xi + yi*yi)*secRMax ;
1945 *validNorm =
false ;
1955 *validNorm =
false ;
1966 *validNorm =
false ;
1981 G4int oldprc = message.precision(16) ;
1982 message <<
"Undefined side for valid surface normal to solid."
1984 <<
"Position:" << G4endl << G4endl
1985 <<
"p.x() = " << p.
x()/
mm <<
" mm" << G4endl
1986 <<
"p.y() = " << p.
y()/
mm <<
" mm" << G4endl
1987 <<
"p.z() = " << p.
z()/
mm <<
" mm" << G4endl << G4endl
1988 <<
"pho at z = " << std::sqrt( p.
x()*p.
x()+p.
y()*p.
y() )/
mm
1989 <<
" mm" << G4endl << G4endl ;
1990 if( p.
x() != 0. || p.
y() != 0.)
1992 message <<
"point phi = " << std::atan2(p.
y(),p.
x())/
degree
1993 <<
" degree" << G4endl << G4endl ;
1995 message <<
"Direction:" << G4endl << G4endl
1996 <<
"v.x() = " << v.
x() << G4endl
1997 <<
"v.y() = " << v.
y() << G4endl
1998 <<
"v.z() = " << v.
z() << G4endl<< G4endl
1999 <<
"Proposed distance :" << G4endl<< G4endl
2000 <<
"snxt = " << snxt/
mm <<
" mm" <<
G4endl ;
2001 message.precision(oldprc) ;
2002 G4Exception(
"G4Cons::DistanceToOut(p,v,..)",
"GeomSolids1002",
2018 G4double safe=0.0, rho, safeR1, safeR2, safeZ, safePhi;
2032 G4cout <<
"pho at z = " << std::sqrt( p.
x()*p.
x()+p.
y()*p.
y() )/
mm
2033 <<
" mm" << G4endl << G4endl ;
2034 if( (p.
x() != 0.) || (p.
x() != 0.) )
2037 <<
" degree" << G4endl << G4endl ;
2039 G4cout.precision(oldprc) ;
2040 G4Exception(
"G4Cons::DistanceToOut(p)",
"GeomSolids1002",
2045 rho = std::sqrt(p.
x()*p.
x() + p.
y()*p.
y()) ;
2046 safeZ =
fDz - std::fabs(p.
z()) ;
2051 secRMin = std::sqrt(1.0 + tanRMin*tanRMin) ;
2053 safeR1 = (rho - pRMin)/secRMin ;
2061 secRMax = std::sqrt(1.0 + tanRMax*tanRMax) ;
2063 safeR2 = (pRMax - rho)/secRMax ;
2065 if (safeR1 < safeR2) { safe = safeR1; }
2066 else { safe = safeR2; }
2067 if (safeZ < safe) { safe = safeZ ; }
2083 if (safePhi < safe) { safe = safePhi; }
2085 if ( safe < 0 ) { safe = 0; }
2105 return new G4Cons(*
this);
2114 G4int oldprc = os.precision(16);
2115 os <<
"-----------------------------------------------------------\n"
2116 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
2117 <<
" ===================================================\n"
2118 <<
" Solid type: G4Cons\n"
2119 <<
" Parameters: \n"
2120 <<
" inside -fDz radius: " <<
fRmin1/
mm <<
" mm \n"
2121 <<
" outside -fDz radius: " <<
fRmax1/
mm <<
" mm \n"
2122 <<
" inside +fDz radius: " <<
fRmin2/
mm <<
" mm \n"
2123 <<
" outside +fDz radius: " <<
fRmax2/
mm <<
" mm \n"
2124 <<
" half length in Z : " <<
fDz/
mm <<
" mm \n"
2125 <<
" starting angle of segment: " <<
fSPhi/
degree <<
" degrees \n"
2126 <<
" delta angle of segment : " <<
fDPhi/
degree <<
" degrees \n"
2127 <<
"-----------------------------------------------------------\n";
2128 os.precision(oldprc);
2165 if( (chose >= 0.) && (chose < Aone) )
2171 rone*sinu*(qone-zRand), zRand);
2179 else if( (chose >= Aone) && (chose < Aone + Atwo) )
2185 rtwo*sinu*(qtwo-zRand), zRand);
2193 else if( (chose >= Aone + Atwo) && (chose < Aone + Atwo + Athree) )
2197 else if( (chose >= Aone + Atwo + Athree)
2198 && (chose < Aone + Atwo + Athree + Afour) )
2202 else if( (chose >= Aone + Atwo + Athree + Afour)
2203 && (chose < Aone + Atwo + Athree + Afour + Afive) )