65 using namespace CLHEP;
93 if ( pDz <= 0 || pDy1 <= 0 || pDx1 <= 0 ||
94 pDx2 <= 0 || pDy2 <= 0 || pDx3 <= 0 || pDx4 <= 0 )
96 std::ostringstream message;
97 message <<
"Invalid length parameters for Solid: " <<
GetName() <<
G4endl
99 << pDx1 <<
", " << pDx2 <<
", " << pDx3 <<
", " << pDx4 <<
G4endl
100 <<
" Y - " << pDy1 <<
", " << pDy2 <<
G4endl
107 fTthetaCphi=std::tan(pTheta)*std::cos(pPhi);
108 fTthetaSphi=std::tan(pTheta)*std::sin(pPhi);
113 fTalpha1=std::tan(pAlp1);
118 fTalpha2=std::tan(pAlp2);
139 && pt[0].
z() == pt[1].
z() && pt[0].
z() == pt[2].
z()
140 && pt[0].
z() == pt[3].
z()
142 && pt[4].
z() == pt[5].
z() && pt[4].
z() == pt[6].
z()
143 && pt[4].
z() == pt[7].
z()
145 && pt[0].
y() == pt[1].
y() && pt[2].
y() == pt[3].
y()
146 && pt[4].
y() == pt[5].
y() && pt[6].
y() == pt[7].
y()
148 && std::fabs( pt[0].
x() + pt[1].
x() + pt[4].
x() + pt[5].
x() +
151 std::ostringstream message;
152 message <<
"Invalid vertice coordinates for Solid: " <<
GetName();
159 good =
MakePlane(pt[0],pt[4],pt[5],pt[1],fPlanes[0]);
165 "Face at ~-Y not planar.");
170 good =
MakePlane(pt[2],pt[3],pt[7],pt[6],fPlanes[1]);
174 std::ostringstream message;
175 message <<
"Face at ~+Y not planar for Solid: " <<
GetName();
182 good =
MakePlane(pt[0],pt[2],pt[6],pt[4],fPlanes[2]);
186 std::ostringstream message;
187 message <<
"Face at ~-X not planar for Solid: " <<
GetName();
194 good =
MakePlane(pt[1],pt[5],pt[7],pt[3],fPlanes[3]);
197 std::ostringstream message;
198 message <<
"Face at ~+X not planar for Solid: " <<
GetName();
204 fDy1 = ((pt[2]).
y()-(pt[1]).
y())*0.5;
205 fDx1 = ((pt[1]).
x()-(pt[0]).
x())*0.5;
206 fDx2 = ((pt[3]).
x()-(pt[2]).
x())*0.5;
207 fTalpha1 = ((pt[2]).
x()+(pt[3]).
x()-(pt[1]).
x()-(pt[0]).
x())*0.25/fDy1;
209 fDy2 = ((pt[6]).
y()-(pt[5]).
y())*0.5;
210 fDx3 = ((pt[5]).
x()-(pt[4]).
x())*0.5;
211 fDx4 = ((pt[7]).
x()-(pt[6]).
x())*0.5;
212 fTalpha2 = ((pt[6]).
x()+(pt[7]).
x()-(pt[5]).
x()-(pt[4]).
x())*0.25/fDy2;
214 fTthetaCphi = ((pt[4]).
x()+fDy2*fTalpha2+fDx3)/fDz;
215 fTthetaSphi = ((pt[4]).
y()+fDy2)/fDz;
230 if ( pZ<=0 || pY<=0 || pX<=0 || pLTX<=0 || pLTX>pX )
232 std::ostringstream message;
233 message <<
"Invalid length parameters for Solid: " <<
GetName();
245 fTalpha1 = 0.5*(pLTX - pX)/pY;
250 fTalpha2 = fTalpha1 ;
255 -fDz*fTthetaSphi-fDy1,-fDz);
257 -fDz*fTthetaSphi-fDy1,-fDz);
259 -fDz*fTthetaSphi+fDy1,-fDz);
261 -fDz*fTthetaSphi+fDy1,-fDz);
263 +fDz*fTthetaSphi-fDy2,+fDz);
265 +fDz*fTthetaSphi-fDy2,+fDz);
267 +fDz*fTthetaSphi+fDy2,+fDz);
269 +fDz*fTthetaSphi+fDy2,+fDz);
273 good=
MakePlane(pt[0],pt[4],pt[5],pt[1],fPlanes[0]);
276 std::ostringstream message;
277 message <<
"Face at ~-Y not planar for Solid: " <<
GetName();
284 good=
MakePlane(pt[2],pt[3],pt[7],pt[6],fPlanes[1]);
287 std::ostringstream message;
288 message <<
"Face at ~+Y not planar for Solid: " <<
GetName();
295 good=
MakePlane(pt[0],pt[2],pt[6],pt[4],fPlanes[2]);
298 std::ostringstream message;
299 message <<
"Face at ~-X not planar for Solid: " <<
GetName();
306 good=
MakePlane(pt[1],pt[5],pt[7],pt[3],fPlanes[3]);
309 std::ostringstream message;
310 message <<
"Face at ~+X not planar for Solid: " <<
GetName();
328 if ( pDz<=0 || pDy1<=0 || pDx1<=0 || pDx2<=0 || pDy2<=0 )
330 std::ostringstream message;
331 message <<
"Invalid length parameters for Solid: " <<
GetName();
353 -fDz*fTthetaSphi-fDy1,-fDz);
355 -fDz*fTthetaSphi-fDy1,-fDz);
357 -fDz*fTthetaSphi+fDy1,-fDz);
359 -fDz*fTthetaSphi+fDy1,-fDz);
361 +fDz*fTthetaSphi-fDy2,+fDz);
363 +fDz*fTthetaSphi-fDy2,+fDz);
365 +fDz*fTthetaSphi+fDy2,+fDz);
367 +fDz*fTthetaSphi+fDy2,+fDz);
371 good=
MakePlane(pt[0],pt[4],pt[5],pt[1],fPlanes[0]);
374 std::ostringstream message;
375 message <<
"Face at ~-Y not planar for Solid: " <<
GetName();
382 good=
MakePlane(pt[2],pt[3],pt[7],pt[6],fPlanes[1]);
385 std::ostringstream message;
386 message <<
"Face at ~+Y not planar for Solid: " <<
GetName();
393 good=
MakePlane(pt[0],pt[2],pt[6],pt[4],fPlanes[2]);
396 std::ostringstream message;
397 message <<
"Face at ~-X not planar for Solid: " <<
GetName();
404 good=
MakePlane(pt[1],pt[5],pt[7],pt[3],fPlanes[3]);
407 std::ostringstream message;
408 message <<
"Face at ~+X not planar for Solid: " <<
GetName();
427 if ( pDz<=0 || pDy<=0 || pDx<=0 )
429 std::ostringstream message;
430 message <<
"Invalid length parameters for Solid: " <<
GetName();
436 fTthetaCphi = std::tan(pTheta)*std::cos(pPhi) ;
437 fTthetaSphi = std::tan(pTheta)*std::sin(pPhi) ;
442 fTalpha1 = std::tan(pAlpha) ;
447 fTalpha2 = fTalpha1 ;
452 -fDz*fTthetaSphi-fDy1,-fDz);
454 -fDz*fTthetaSphi-fDy1,-fDz);
456 -fDz*fTthetaSphi+fDy1,-fDz);
458 -fDz*fTthetaSphi+fDy1,-fDz);
460 +fDz*fTthetaSphi-fDy2,+fDz);
462 +fDz*fTthetaSphi-fDy2,+fDz);
464 +fDz*fTthetaSphi+fDy2,+fDz);
466 +fDz*fTthetaSphi+fDy2,+fDz);
470 good=
MakePlane(pt[0],pt[4],pt[5],pt[1],fPlanes[0]);
473 std::ostringstream message;
474 message <<
"Face at ~-Y not planar for Solid: " <<
GetName();
481 good=
MakePlane(pt[2],pt[3],pt[7],pt[6],fPlanes[1]);
484 std::ostringstream message;
485 message <<
"Face at ~+Y not planar for Solid: " <<
GetName();
492 good=
MakePlane(pt[0],pt[2],pt[6],pt[4],fPlanes[2]);
495 std::ostringstream message;
496 message <<
"Face at ~-X not planar for Solid: " <<
GetName();
503 good=
MakePlane(pt[1],pt[5],pt[7],pt[3],fPlanes[3]);
506 std::ostringstream message;
507 message <<
"Face at ~+X not planar for Solid: " <<
GetName();
520 :
G4CSGSolid (pName), fDz(1.), fTthetaCphi(0.), fTthetaSphi(0.),
521 fDy1(1.), fDx1(1.), fDx2(1.), fTalpha1(0.),
522 fDy2(1.), fDx3(1.), fDx4(1.), fTalpha2(0.)
533 :
G4CSGSolid(a), fDz(1.), fTthetaCphi(0.), fTthetaSphi(0.),
534 fDy1(1.), fDx1(1.), fDx2(1.), fTalpha1(0.),
535 fDy2(1.), fDx3(1.), fDx4(1.), fTalpha2(0.)
554 fTthetaCphi(rhs.fTthetaCphi), fTthetaSphi(rhs.fTthetaSphi),
555 fDy1(rhs.fDy1), fDx1(rhs.fDx1), fDx2(rhs.fDx2), fTalpha1(rhs.fTalpha1),
556 fDy2(rhs.fDy2), fDx3(rhs.fDx3), fDx4(rhs.fDx4), fTalpha2(rhs.fTalpha2)
558 for (
size_t i=0; i<4; ++i)
560 fPlanes[i].
a = rhs.fPlanes[i].
a;
561 fPlanes[i].
b = rhs.fPlanes[i].
b;
562 fPlanes[i].
c = rhs.fPlanes[i].
c;
563 fPlanes[i].
d = rhs.fPlanes[i].
d;
575 if (
this == &rhs) {
return *
this; }
584 fTthetaCphi = rhs.fTthetaCphi; fTthetaSphi = rhs.fTthetaSphi;
585 fDy1 = rhs.fDy1; fDx1 = rhs.fDx1; fDx2 = rhs.fDx2; fTalpha1 = rhs.fTalpha1;
586 fDy2 = rhs.fDy2; fDx3 = rhs.fDx3; fDx4 = rhs.fDx4; fTalpha2 = rhs.fTalpha2;
587 for (
size_t i=0; i<4; ++i)
589 fPlanes[i].
a = rhs.fPlanes[i].
a;
590 fPlanes[i].
b = rhs.fPlanes[i].
b;
591 fPlanes[i].
c = rhs.fPlanes[i].
c;
592 fPlanes[i].
d = rhs.fPlanes[i].
d;
615 if ( pDz<=0 || pDy1<=0 || pDx1<=0 || pDx2<=0 || pDy2<=0 || pDx3<=0 || pDx4<=0 )
617 std::ostringstream message;
618 message <<
"Invalid Length Parameters for Solid: " <<
GetName() <<
G4endl
620 << pDx1 <<
", " << pDx2 <<
", " << pDx3 <<
", " << pDx4 <<
G4endl
621 <<
" Y - " << pDy1 <<
", " << pDy2 <<
G4endl
623 G4Exception(
"G4Trap::SetAllParameters()",
"GeomSolids0002",
630 fTthetaCphi=std::tan(pTheta)*std::cos(pPhi);
631 fTthetaSphi=std::tan(pTheta)*std::sin(pPhi);
636 fTalpha1=std::tan(pAlp1);
641 fTalpha2=std::tan(pAlp2);
657 -fDz*fTthetaSphi-fDy1,-fDz);
659 -fDz*fTthetaSphi-fDy1,-fDz);
661 -fDz*fTthetaSphi+fDy1,-fDz);
663 -fDz*fTthetaSphi+fDy1,-fDz);
665 +fDz*fTthetaSphi-fDy2,+fDz);
667 +fDz*fTthetaSphi-fDy2,+fDz);
669 +fDz*fTthetaSphi+fDy2,+fDz);
671 +fDz*fTthetaSphi+fDy2,+fDz);
675 good=
MakePlane(pt[0],pt[4],pt[5],pt[1],fPlanes[0]) ;
678 std::ostringstream message;
679 message <<
"Face at ~-Y not planar for Solid: " <<
GetName();
680 G4Exception(
"G4Trap::MakePlanes()",
"GeomSolids0002",
686 good=
MakePlane(pt[2],pt[3],pt[7],pt[6],fPlanes[1]);
689 std::ostringstream message;
690 message <<
"Face at ~+Y not planar for Solid: " <<
GetName();
691 G4Exception(
"G4Trap::MakePlanes()",
"GeomSolids0002",
697 good=
MakePlane(pt[0],pt[2],pt[6],pt[4],fPlanes[2]);
700 std::ostringstream message;
701 message <<
"Face at ~-X not planar for Solid: " <<
GetName();
702 G4Exception(
"G4Trap::MakePlanes()",
"GeomSolids0002",
708 good =
MakePlane(pt[1],pt[5],pt[7],pt[3],fPlanes[3]);
711 std::ostringstream message;
712 message <<
"Face at ~+X not planar for Solid: " <<
GetName();
713 G4Exception(
"G4Trap::MakePlanes()",
"GeomSolids0002",
743 Vcross = v12.
cross(v13);
765 a = +(p4.
y() - p2.
y())*(p3.
z() - p1.z())
766 - (p3.
y() - p1.y())*(p4.
z() - p2.
z());
768 b = -(p4.
x() - p2.
x())*(p3.
z() - p1.z())
769 + (p3.
x() - p1.x())*(p4.
z() - p2.
z());
771 c = +(p4.
x() - p2.
x())*(p3.
y() - p1.y())
772 - (p3.
x() - p1.x())*(p4.
y() - p2.
y());
774 sd = std::sqrt( a*a + b*b + c*c );
784 std::ostringstream message;
785 message <<
"Invalid parameters: norm.mod() <= 0, for Solid: "
787 G4Exception(
"G4Trap::MakePlanes()",
"GeomSolids0002",
792 plane.
d = -( plane.
a*p1.x() + plane.
b*p1.y() + plane.
c*p1.z() );
821 G4double xMin, xMax, yMin, yMax, zMin, zMax;
841 pt[0]=
G4ThreeVector(xoffset-fDz*fTthetaCphi-fDy1*fTalpha1-fDx1,
842 yoffset-fDz*fTthetaSphi-fDy1,zoffset-fDz);
843 pt[1]=
G4ThreeVector(xoffset-fDz*fTthetaCphi-fDy1*fTalpha1+fDx1,
844 yoffset-fDz*fTthetaSphi-fDy1,zoffset-fDz);
845 pt[2]=
G4ThreeVector(xoffset-fDz*fTthetaCphi+fDy1*fTalpha1-fDx2,
846 yoffset-fDz*fTthetaSphi+fDy1,zoffset-fDz);
847 pt[3]=
G4ThreeVector(xoffset-fDz*fTthetaCphi+fDy1*fTalpha1+fDx2,
848 yoffset-fDz*fTthetaSphi+fDy1,zoffset-fDz);
849 pt[4]=
G4ThreeVector(xoffset+fDz*fTthetaCphi-fDy2*fTalpha2-fDx3,
850 yoffset+fDz*fTthetaSphi-fDy2,zoffset+fDz);
851 pt[5]=
G4ThreeVector(xoffset+fDz*fTthetaCphi-fDy2*fTalpha2+fDx3,
852 yoffset+fDz*fTthetaSphi-fDy2,zoffset+fDz);
853 pt[6]=
G4ThreeVector(xoffset+fDz*fTthetaCphi+fDy2*fTalpha2-fDx4,
854 yoffset+fDz*fTthetaSphi+fDy2,zoffset+fDz);
855 pt[7]=
G4ThreeVector(xoffset+fDz*fTthetaCphi+fDy2*fTalpha2+fDx4,
856 yoffset+fDz*fTthetaSphi+fDy2,zoffset+fDz);
879 temp[0] = pt[0].
y()+(pt[4].
y()-pt[0].
y())*(zMin-pt[0].
z())
880 /(pt[4].
z()-pt[0].
z()) ;
881 temp[1] = pt[0].
y()+(pt[4].
y()-pt[0].
y())*(zMax-pt[0].
z())
882 /(pt[4].
z()-pt[0].
z()) ;
883 temp[2] = pt[2].
y()+(pt[6].
y()-pt[2].
y())*(zMin-pt[2].
z())
884 /(pt[6].
z()-pt[2].
z()) ;
885 temp[3] = pt[2].
y()+(pt[6].
y()-pt[2].
y())*(zMax-pt[2].
z())
886 /(pt[6].
z()-pt[2].
z()) ;
888 yMax = yoffset - std::fabs(fDz*fTthetaSphi) - fDy1 - fDy2 ;
891 for( i = 0 ; i < 4 ; i++ )
893 if( temp[i] > yMax ) yMax = temp[i] ;
894 if( temp[i] < yMin ) yMin = temp[i] ;
915 temp[0] = pt[0].
x()+(pt[4].
x()-pt[0].
x())
916 *(zMin-pt[0].
z())/(pt[4].
z()-pt[0].
z()) ;
917 temp[1] = pt[0].
x()+(pt[4].
x()-pt[0].
x())
918 *(zMax-pt[0].
z())/(pt[4].
z()-pt[0].
z()) ;
919 temp[2] = pt[2].
x()+(pt[6].
x()-pt[2].
x())
920 *(zMin-pt[2].
z())/(pt[6].
z()-pt[2].
z()) ;
921 temp[3] = pt[2].
x()+(pt[6].
x()-pt[2].
x())
922 *(zMax-pt[2].
z())/(pt[6].
z()-pt[2].
z()) ;
923 temp[4] = pt[3].
x()+(pt[7].
x()-pt[3].
x())
924 *(zMin-pt[3].
z())/(pt[7].
z()-pt[3].
z()) ;
925 temp[5] = pt[3].
x()+(pt[7].
x()-pt[3].
x())
926 *(zMax-pt[3].
z())/(pt[7].
z()-pt[3].
z()) ;
927 temp[6] = pt[1].
x()+(pt[5].
x()-pt[1].
x())
928 *(zMin-pt[1].
z())/(pt[5].
z()-pt[1].
z()) ;
929 temp[7] = pt[1].
x()+(pt[5].
x()-pt[1].
x())
930 *(zMax-pt[1].
z())/(pt[5].
z()-pt[1].
z()) ;
932 xMax = xoffset - std::fabs(fDz*fTthetaCphi) - fDx1 - fDx2 -fDx3 - fDx4 ;
935 for( i = 0 ; i < 8 ; i++ )
937 if( temp[i] > xMax) xMax = temp[i] ;
938 if( temp[i] < xMin) xMin = temp[i] ;
986 G4bool existsAfterClip = false ;
995 xMin = +kInfinity; yMin = +kInfinity; zMin = +kInfinity;
996 xMax = -kInfinity; yMax = -kInfinity; zMax = -kInfinity;
998 for(
G4int nv = 0 ; nv < 8 ; nv++ )
1000 if( (*vertices)[nv].
x() > xMax ) xMax = (*vertices)[nv].x();
1001 if( (*vertices)[nv].
y() > yMax ) yMax = (*vertices)[nv].y();
1002 if( (*vertices)[nv].
z() > zMax ) zMax = (*vertices)[nv].z();
1004 if( (*vertices)[nv].
x() < xMin ) xMin = (*vertices)[nv].x();
1005 if( (*vertices)[nv].
y() < yMin ) yMin = (*vertices)[nv].y();
1006 if( (*vertices)[nv].
z() < zMin ) zMin = (*vertices)[nv].z();
1088 if ( (pMin != kInfinity) || (pMax != -kInfinity) )
1090 existsAfterClip=
true;
1098 flag = existsAfterClip ;
1117 for ( i = 0;i < 4;i++ )
1119 Dist = fPlanes[i].
a*p.
x() + fPlanes[i].
b*p.
y()
1120 +fPlanes[i].
c*p.
z() + fPlanes[i].
d;
1131 for ( i = 0; i < 4; i++ )
1133 Dist = fPlanes[i].
a*p.
x() + fPlanes[i].
b*p.
y()
1134 +fPlanes[i].
c*p.
z() + fPlanes[i].
d;
1151 G4int i, noSurfaces = 0;
1152 G4double dist, distz, distx, disty, distmx, distmy, safe = kInfinity;
1156 for (i = 0; i < 4; i++)
1158 dist = std::fabs(fPlanes[i].
a*p.
x() + fPlanes[i].
b*p.
y()
1159 + fPlanes[i].
c*p.
z() + fPlanes[i].
d);
1165 distz = std::fabs( std::fabs( p.
z() ) - fDz );
1167 distmy = std::fabs( fPlanes[0].
a*p.
x() + fPlanes[0].
b*p.
y()
1168 + fPlanes[0].
c*p.
z() + fPlanes[0].
d );
1170 disty = std::fabs( fPlanes[1].
a*p.
x() + fPlanes[1].
b*p.
y()
1171 + fPlanes[1].
c*p.
z() + fPlanes[1].
d );
1173 distmx = std::fabs( fPlanes[2].
a*p.
x() + fPlanes[2].
b*p.
y()
1174 + fPlanes[2].
c*p.
z() + fPlanes[2].
d );
1176 distx = std::fabs( fPlanes[3].
a*p.
x() + fPlanes[3].
b*p.
y()
1177 + fPlanes[3].
c*p.
z() + fPlanes[3].
d );
1190 if (distmx <= delta)
1200 if (distmy <= delta)
1208 if ( p.
z() >= 0.) sumnorm += nZ;
1211 if ( noSurfaces == 0 )
1214 G4Exception(
"G4Trap::SurfaceNormal(p)",
"GeomSolids1002",
1217 norm = ApproxSurfaceNormal(p);
1219 else if ( noSurfaces == 1 ) norm = sumnorm;
1220 else norm = sumnorm.
unit();
1231 G4double safe=kInfinity,Dist,safez;
1235 Dist=std::fabs(fPlanes[i].
a*p.
x()+fPlanes[i].
b*p.
y()
1236 +fPlanes[i].
c*p.
z()+fPlanes[i].
d);
1243 safez=std::fabs(std::fabs(p.
z())-fDz);
1287 smin = (-fDz-p.
z())/v.
z();
1291 return snxt=kInfinity;
1294 else if (v.
z() < 0 )
1296 max = - fDz - p.
z() ;
1300 smin=(fDz-p.
z())/v.
z();
1304 return snxt=kInfinity;
1316 return snxt=kInfinity;
1322 pdist=fPlanes[i].
a*p.
x()+fPlanes[i].
b*p.
y()
1323 +fPlanes[i].
c*p.
z()+fPlanes[i].
d;
1324 Comp=fPlanes[i].
a*v.
x()+fPlanes[i].
b*v.
y()+fPlanes[i].
c*v.
z();
1332 return snxt=kInfinity ;
1345 return snxt=kInfinity;
1366 return snxt=kInfinity;
1396 safe=std::fabs(p.
z())-fDz;
1399 Dist=fPlanes[i].
a*p.
x()+fPlanes[i].
b*p.
y()
1400 +fPlanes[i].
c*p.
z()+fPlanes[i].
d;
1401 if (Dist > safe) safe=Dist;
1466 pdist=fPlanes[0].
a*p.
x()+fPlanes[0].
b*p.
y()+fPlanes[0].
c*p.
z()+fPlanes[0].
d;
1467 Comp=fPlanes[0].
a*v.
x()+fPlanes[0].
b*v.
y()+fPlanes[0].
c*v.
z();
1513 pdist=fPlanes[1].
a*p.
x()+fPlanes[1].
b*p.
y()+fPlanes[1].
c*p.
z()+fPlanes[1].
d;
1514 Comp=fPlanes[1].
a*v.
x()+fPlanes[1].
b*v.
y()+fPlanes[1].
c*v.
z();
1560 pdist=fPlanes[2].
a*p.
x()+fPlanes[2].
b*p.
y()+fPlanes[2].
c*p.
z()+fPlanes[2].
d;
1561 Comp=fPlanes[2].
a*v.
x()+fPlanes[2].
b*v.
y()+fPlanes[2].
c*v.
z();
1607 pdist=fPlanes[3].
a*p.
x()+fPlanes[3].
b*p.
y()+fPlanes[3].
c*p.
z()+fPlanes[3].
d;
1608 Comp=fPlanes[3].
a*v.
x()+fPlanes[3].
b*v.
y()+fPlanes[3].
c*v.
z();
1678 std::ostringstream message;
1679 G4int oldprc = message.precision(16);
1680 message <<
"Undefined side for valid surface normal to solid."
1682 <<
"Position:" << G4endl << G4endl
1683 <<
"p.x() = " << p.
x()/
mm <<
" mm" << G4endl
1684 <<
"p.y() = " << p.
y()/
mm <<
" mm" << G4endl
1685 <<
"p.z() = " << p.
z()/
mm <<
" mm" << G4endl << G4endl
1686 <<
"Direction:" << G4endl << G4endl
1687 <<
"v.x() = " << v.
x() << G4endl
1688 <<
"v.y() = " << v.
y() << G4endl
1689 <<
"v.z() = " << v.
z() << G4endl << G4endl
1690 <<
"Proposed distance :" << G4endl << G4endl
1691 <<
"snxt = " << snxt/
mm <<
" mm" <<
G4endl;
1692 message.precision(oldprc);
1693 G4Exception(
"G4Trap::DistanceToOut(p,v,..)",
"GeomSolids1002",
1721 G4cout.precision(oldprc) ;
1723 "GeomSolids1002",
JustWarning,
"Point p is outside !?" );
1727 safe=fDz-std::fabs(p.
z());
1733 Dist=-(fPlanes[i].
a*p.
x()+fPlanes[i].
b*p.
y()
1734 +fPlanes[i].
c*p.
z()+fPlanes[i].
d);
1735 if (Dist<safe) safe=Dist;
1758 vertices->reserve(8);
1760 -fDz*fTthetaSphi-fDy1,-fDz);
1762 -fDz*fTthetaSphi-fDy1,-fDz);
1764 -fDz*fTthetaSphi+fDy1,-fDz);
1766 -fDz*fTthetaSphi+fDy1,-fDz);
1768 +fDz*fTthetaSphi-fDy2,+fDz);
1770 +fDz*fTthetaSphi-fDy2,+fDz);
1772 +fDz*fTthetaSphi+fDy2,+fDz);
1774 +fDz*fTthetaSphi+fDy2,+fDz);
1790 "Error in allocation of vertices. Out of memory !");
1810 return new G4Trap(*
this);
1819 G4int oldprc = os.precision(16);
1820 os <<
"-----------------------------------------------------------\n"
1821 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
1822 <<
" ===================================================\n"
1823 <<
" Solid type: G4Trap\n"
1824 <<
" Parameters: \n"
1825 <<
" half length Z: " << fDz/
mm <<
" mm \n"
1826 <<
" half length Y of face -fDz: " << fDy1/
mm <<
" mm \n"
1827 <<
" half length X of side -fDy1, face -fDz: " << fDx1/
mm <<
" mm \n"
1828 <<
" half length X of side +fDy1, face -fDz: " << fDx2/
mm <<
" mm \n"
1829 <<
" half length Y of face +fDz: " << fDy2/
mm <<
" mm \n"
1830 <<
" half length X of side -fDy2, face +fDz: " << fDx3/
mm <<
" mm \n"
1831 <<
" half length X of side +fDy2, face +fDz: " << fDx4/
mm <<
" mm \n"
1832 <<
" std::tan(theta)*std::cos(phi): " << fTthetaCphi/
degree <<
" degrees \n"
1833 <<
" std::tan(theta)*std::sin(phi): " << fTthetaSphi/
degree <<
" degrees \n"
1834 <<
" std::tan(alpha), -fDz: " << fTalpha1/
degree <<
" degrees \n"
1835 <<
" std::tan(alpha), +fDz: " << fTalpha2/
degree <<
" degrees \n"
1836 <<
" trap side plane equations:\n"
1837 <<
" " << fPlanes[0].
a <<
" X + " << fPlanes[0].
b <<
" Y + "
1838 << fPlanes[0].
c <<
" Z + " << fPlanes[0].
d <<
" = 0\n"
1839 <<
" " << fPlanes[1].
a <<
" X + " << fPlanes[1].
b <<
" Y + "
1840 << fPlanes[1].
c <<
" Z + " << fPlanes[1].
d <<
" = 0\n"
1841 <<
" " << fPlanes[2].
a <<
" X + " << fPlanes[2].
b <<
" Y + "
1842 << fPlanes[2].
c <<
" Z + " << fPlanes[2].
d <<
" = 0\n"
1843 <<
" " << fPlanes[3].
a <<
" X + " << fPlanes[3].
b <<
" Y + "
1844 << fPlanes[3].
c <<
" Z + " << fPlanes[3].
d <<
" = 0\n"
1845 <<
"-----------------------------------------------------------\n";
1846 os.precision(oldprc);
1861 G4double lambda1, lambda2, chose, aOne, aTwo;
1870 w.
z()*v.
x() - w.
x()*v.
z(),
1871 w.
x()*v.
y() - w.
y()*v.
x());
1873 aOne = 0.5*Area.
mag();
1876 t.
z()*u.
x() - t.
x()*u.
z(),
1877 t.
x()*u.
y() - t.
y()*u.
x());
1879 aTwo = 0.5*Area.
mag();
1883 chose = RandFlat::shoot(0.,aOne+aTwo);
1885 if( (chose>=0.) && (chose < aOne) )
1887 lambda1 = RandFlat::shoot(0.,1.);
1888 lambda2 = RandFlat::shoot(0.,lambda1);
1889 return (p2+lambda1*v+lambda2*w);
1894 lambda1 = RandFlat::shoot(0.,1.);
1895 lambda2 = RandFlat::shoot(0.,lambda1);
1897 return (p0+lambda1*t+lambda2*u);
1906 G4double aOne, aTwo, aThree, aFour, aFive, aSix, chose;
1911 -fDz*fTthetaSphi-fDy1,-fDz);
1913 -fDz*fTthetaSphi-fDy1,-fDz);
1915 -fDz*fTthetaSphi+fDy1,-fDz);
1917 -fDz*fTthetaSphi+fDy1,-fDz);
1919 +fDz*fTthetaSphi-fDy2,+fDz);
1921 +fDz*fTthetaSphi-fDy2,+fDz);
1923 +fDz*fTthetaSphi+fDy2,+fDz);
1925 +fDz*fTthetaSphi+fDy2,+fDz);
1929 One = GetPointOnPlane(pt[0],pt[1],pt[3],pt[2], aOne);
1930 Two = GetPointOnPlane(pt[4],pt[5],pt[7],pt[6], aTwo);
1931 Three = GetPointOnPlane(pt[6],pt[7],pt[3],pt[2], aThree);
1932 Four = GetPointOnPlane(pt[4],pt[5],pt[1],pt[0], aFour);
1933 Five = GetPointOnPlane(pt[0],pt[2],pt[6],pt[4], aFive);
1934 Six = GetPointOnPlane(pt[1],pt[3],pt[7],pt[5], aSix);
1936 chose = RandFlat::shoot(0.,aOne+aTwo+aThree+aFour+aFive+aSix);
1937 if( (chose>=0.) && (chose<aOne) )
1939 else if( (chose>=aOne) && (chose<aOne+aTwo) )
1941 else if( (chose>=aOne+aTwo) && (chose<aOne+aTwo+aThree) )
1943 else if( (chose>=aOne+aTwo+aThree) && (chose<aOne+aTwo+aThree+aFour) )
1945 else if( (chose>=aOne+aTwo+aThree+aFour)
1946 && (chose<aOne+aTwo+aThree+aFour+aFive) )
1962 G4double phi = std::atan2(fTthetaSphi, fTthetaCphi);
1963 G4double alpha1 = std::atan(fTalpha1);
1964 G4double alpha2 = std::atan(fTalpha2);
1965 G4double theta = std::atan(std::sqrt(fTthetaCphi*fTthetaCphi+fTthetaSphi*fTthetaSphi));
1968 fDy1, fDx1, fDx2, alpha1,
1969 fDy2, fDx3, fDx4, alpha2);