37#if !defined(G4GEOM_USE_UTRAP)
76 fTthetaCphi = std::tan(pTheta)*std::cos(pPhi);
77 fTthetaSphi = std::tan(pTheta)*std::sin(pPhi);
79 fDy1 = pDy1; fDx1 = pDx1; fDx2 = pDx2; fTalpha1 = std::tan(pAlp1);
80 fDy2 = pDy2; fDx3 = pDx3; fDx4 = pDx4; fTalpha2 = std::tan(pAlp2);
100 || pt[0].z() != pt[1].z()
101 || pt[0].z() != pt[2].z()
102 || pt[0].z() != pt[3].z()
105 || pt[4].z() != pt[5].z()
106 || pt[4].z() != pt[6].z()
107 || pt[4].z() != pt[7].z()
111 || pt[0].y() != pt[1].y()
112 || pt[2].y() != pt[3].y()
113 || pt[4].y() != pt[5].y()
114 || pt[6].y() != pt[7].y()
116 || std::fabs(pt[0].y()+pt[2].y()+pt[4].y()+pt[6].y()) >=
kCarTolerance
117 || std::fabs(pt[0].x()+pt[1].x()+pt[4].x()+pt[5].x() +
120 std::ostringstream message;
121 message <<
"Invalid vertice coordinates for Solid: " <<
GetName();
130 fDy1 = ((pt[2]).y()-(pt[1]).y())*0.5;
131 fDx1 = ((pt[1]).x()-(pt[0]).x())*0.5;
132 fDx2 = ((pt[3]).x()-(pt[2]).x())*0.5;
133 fTalpha1 = ((pt[2]).x()+(pt[3]).x()-(pt[1]).x()-(pt[0]).x())*0.25/fDy1;
135 fDy2 = ((pt[6]).y()-(pt[5]).y())*0.5;
136 fDx3 = ((pt[5]).x()-(pt[4]).x())*0.5;
137 fDx4 = ((pt[7]).x()-(pt[6]).x())*0.5;
138 fTalpha2 = ((pt[6]).x()+(pt[7]).x()-(pt[5]).x()-(pt[4]).x())*0.25/fDy2;
140 fTthetaCphi = ((pt[4]).x()+fDy2*fTalpha2+fDx3)/fDz;
141 fTthetaSphi = ((pt[4]).y()+fDy2)/fDz;
157 fDz = 0.5*pZ; fTthetaCphi = 0; fTthetaSphi = 0;
158 fDy1 = 0.5*pY; fDx1 = 0.5*pX; fDx2 = 0.5*pLTX; fTalpha1 = 0.5*(pLTX - pX)/pY;
159 fDy2 = fDy1; fDx3 = fDx1; fDx4 = fDx2; fTalpha2 = fTalpha1;
175 fDz = pDz; fTthetaCphi = 0; fTthetaSphi = 0;
176 fDy1 = pDy1; fDx1 = pDx1; fDx2 = pDx1; fTalpha1 = 0;
177 fDy2 = pDy2; fDx3 = pDx2; fDx4 = pDx2; fTalpha2 = 0;
195 fTthetaCphi = std::tan(pTheta)*std::cos(pPhi);
196 fTthetaSphi = std::tan(pTheta)*std::sin(pPhi);
198 fDy1 = pDy; fDx1 = pDx; fDx2 = pDx; fTalpha1 = std::tan(pAlpha);
199 fDy2 = pDy; fDx3 = pDx; fDx4 = pDx; fTalpha2 = fTalpha1;
213 fDz(1.), fTthetaCphi(0.), fTthetaSphi(0.),
214 fDy1(1.), fDx1(1.), fDx2(1.), fTalpha1(0.),
215 fDy2(1.), fDx3(1.), fDx4(1.), fTalpha2(0.)
227 fDz(1.), fTthetaCphi(0.), fTthetaSphi(0.),
228 fDy1(1.), fDx1(1.), fDx2(1.), fTalpha1(0.),
229 fDy2(1.), fDx3(1.), fDx4(1.), fTalpha2(0.)
239 :
G4CSGSolid(rhs), halfCarTolerance(rhs.halfCarTolerance),
240 fDz(rhs.fDz), fTthetaCphi(rhs.fTthetaCphi), fTthetaSphi(rhs.fTthetaSphi),
241 fDy1(rhs.fDy1), fDx1(rhs.fDx1), fDx2(rhs.fDx2), fTalpha1(rhs.fTalpha1),
242 fDy2(rhs.fDy2), fDx3(rhs.fDx3), fDx4(rhs.fDx4), fTalpha2(rhs.fTalpha2)
244 for (
G4int i=0; i<4; ++i) { fPlanes[i] = rhs.fPlanes[i]; }
245 for (
G4int i=0; i<6; ++i) { fAreas[i] = rhs.fAreas[i]; }
246 fTrapType = rhs.fTrapType;
257 if (
this == &rhs) {
return *
this; }
265 halfCarTolerance = rhs.halfCarTolerance;
266 fDz = rhs.fDz; fTthetaCphi = rhs.fTthetaCphi; fTthetaSphi = rhs.fTthetaSphi;
267 fDy1 = rhs.fDy1; fDx1 = rhs.fDx1; fDx2 = rhs.fDx2; fTalpha1 = rhs.fTalpha1;
268 fDy2 = rhs.fDy2; fDx3 = rhs.fDx3; fDx4 = rhs.fDx4; fTalpha2 = rhs.fTalpha2;
269 for (
G4int i=0; i<4; ++i) { fPlanes[i] = rhs.fPlanes[i]; }
270 for (
G4int i=0; i<6; ++i) { fAreas[i] = rhs.fAreas[i]; }
271 fTrapType = rhs.fTrapType;
299 fTthetaCphi = std::tan(pTheta)*std::cos(pPhi);
300 fTthetaSphi = std::tan(pTheta)*std::sin(pPhi);
302 fDy1 = pDy1; fDx1 = pDx1; fDx2 = pDx2; fTalpha1 = std::tan(pAlp1);
303 fDy2 = pDy2; fDx3 = pDx3; fDx4 = pDx4; fTalpha2 = std::tan(pAlp2);
313void G4Trap::CheckParameters()
316 fDy1<=0 || fDx1<=0 || fDx2<=0 ||
317 fDy2<=0 || fDx3<=0 || fDx4<=0)
319 std::ostringstream message;
320 message <<
"Invalid Length Parameters for Solid: " <<
GetName()
321 <<
"\n X - " <<fDx1<<
", "<<fDx2<<
", "<<fDx3<<
", "<<fDx4
322 <<
"\n Y - " <<fDy1<<
", "<<fDy2
324 G4Exception(
"G4Trap::CheckParameters()",
"GeomSolids0002",
335 G4double DzTthetaCphi = fDz*fTthetaCphi;
336 G4double DzTthetaSphi = fDz*fTthetaSphi;
337 G4double Dy1Talpha1 = fDy1*fTalpha1;
338 G4double Dy2Talpha2 = fDy2*fTalpha2;
342 G4ThreeVector(-DzTthetaCphi-Dy1Talpha1-fDx1,-DzTthetaSphi-fDy1,-fDz),
343 G4ThreeVector(-DzTthetaCphi-Dy1Talpha1+fDx1,-DzTthetaSphi-fDy1,-fDz),
344 G4ThreeVector(-DzTthetaCphi+Dy1Talpha1-fDx2,-DzTthetaSphi+fDy1,-fDz),
345 G4ThreeVector(-DzTthetaCphi+Dy1Talpha1+fDx2,-DzTthetaSphi+fDy1,-fDz),
346 G4ThreeVector( DzTthetaCphi-Dy2Talpha2-fDx3, DzTthetaSphi-fDy2, fDz),
347 G4ThreeVector( DzTthetaCphi-Dy2Talpha2+fDx3, DzTthetaSphi-fDy2, fDz),
348 G4ThreeVector( DzTthetaCphi+Dy2Talpha2-fDx4, DzTthetaSphi+fDy2, fDz),
349 G4ThreeVector( DzTthetaCphi+Dy2Talpha2+fDx4, DzTthetaSphi+fDy2, fDz)
361 constexpr G4int iface[4][4] = { {0,4,5,1}, {2,3,7,6}, {0,2,6,4}, {1,5,7,3} };
362 const static G4String side[4] = {
"~-Y",
"~+Y",
"~-X",
"~+X" };
364 for (
G4int i=0; i<4; ++i)
370 fPlanes[i])) {
continue; }
373 G4ThreeVector normal(fPlanes[i].a,fPlanes[i].b,fPlanes[i].c);
375 for (
G4int k=0; k<4; ++k)
377 G4double dist = normal.dot(pt[iface[i][k]]) + fPlanes[i].d;
378 if (std::abs(dist) > std::abs(dmax)) { dmax = dist; }
380 std::ostringstream message;
381 message <<
"Side face " << side[i] <<
" is not planar for solid: "
382 <<
GetName() <<
"\nDiscrepancy: " << dmax/mm <<
" mm\n";
384 G4Exception(
"G4Trap::MakePlanes()",
"GeomSolids0002",
407 if (std::abs(normal.x()) <
DBL_EPSILON) { normal.setX(0); }
408 if (std::abs(normal.y()) <
DBL_EPSILON) { normal.setY(0); }
409 if (std::abs(normal.z()) <
DBL_EPSILON) { normal.setZ(0); }
410 normal = normal.unit();
413 plane.
a = normal.x();
414 plane.
b = normal.y();
415 plane.
c = normal.z();
416 plane.
d = -normal.dot(centre);
419 G4double d1 = std::abs(normal.dot(p1) + plane.
d);
420 G4double d2 = std::abs(normal.dot(p2) + plane.
d);
421 G4double d3 = std::abs(normal.dot(p3) + plane.
d);
422 G4double d4 = std::abs(normal.dot(p4) + plane.
d);
423 G4double dmax = std::max(std::max(std::max(d1,d2),d3),d4);
435 constexpr G4int iface[6][4] =
436 { {0,1,3,2}, {0,4,5,1}, {2,3,7,6}, {0,2,6,4}, {1,5,7,3}, {4,6,7,5} };
443 for (
G4int i=0; i<6; ++i)
448 pt[iface[i][3]]).
mag();
450 for (
G4int i=1; i<6; ++i) { fAreas[i] += fAreas[i - 1]; }
454 if (fPlanes[0].b == -1 && fPlanes[1].b == 1 &&
461 if (std::abs(fPlanes[2].a + fPlanes[3].a) <
DBL_EPSILON &&
462 std::abs(fPlanes[2].c - fPlanes[3].c) <
DBL_EPSILON &&
467 fPlanes[2].a = -fPlanes[3].a;
468 fPlanes[2].c = fPlanes[3].c;
470 if (std::abs(fPlanes[2].a + fPlanes[3].a) <
DBL_EPSILON &&
471 std::abs(fPlanes[2].b - fPlanes[3].b) <
DBL_EPSILON &&
476 fPlanes[2].a = -fPlanes[3].a;
477 fPlanes[2].b = fPlanes[3].b;
503 G4double xmin = kInfinity, xmax = -kInfinity;
504 G4double ymin = kInfinity, ymax = -kInfinity;
505 for (
const auto & i : pt)
508 if (x < xmin) { xmin = x; }
509 if (x > xmax) { xmax = x; }
511 if (y < ymin) { ymin = y; }
512 if (y > ymax) { ymax = y; }
516 pMin.
set(xmin,ymin,-dz);
517 pMax.
set(xmax,ymax, dz);
521 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
523 std::ostringstream message;
524 message <<
"Bad bounding box (min >= max) for solid: "
526 <<
"\npMin = " << pMin
527 <<
"\npMax = " << pMax;
528 G4Exception(
"G4Trap::BoundingLimits()",
"GeomMgt0001",
555 return exist = pMin < pMax;
574 std::vector<const G4ThreeVectorList *> polygons(2);
575 polygons[0] = &baseA;
576 polygons[1] = &baseB;
594 G4double dy1 = fPlanes[0].b*p.
y()+fPlanes[0].c*p.
z()+fPlanes[0].d;
595 G4double dy2 = fPlanes[1].b*p.
y()+fPlanes[1].c*p.
z()+fPlanes[1].d;
596 G4double dy = std::max(dz,std::max(dy1,dy2));
598 G4double dx1 = fPlanes[2].a*p.
x()+fPlanes[2].b*p.
y()
599 + fPlanes[2].c*p.
z()+fPlanes[2].d;
600 G4double dx2 = fPlanes[3].a*p.
x()+fPlanes[3].b*p.
y()
601 + fPlanes[3].c*p.
z()+fPlanes[3].d;
602 G4double dist = std::max(dy,std::max(dx1,dx2));
604 return (dist > halfCarTolerance) ?
kOutside :
610 G4double dy = std::max(dz,std::abs(p.
y())+fPlanes[1].d);
611 G4double dx1 = fPlanes[2].a*p.
x()+fPlanes[2].b*p.
y()
612 + fPlanes[2].c*p.
z()+fPlanes[2].d;
613 G4double dx2 = fPlanes[3].a*p.
x()+fPlanes[3].b*p.
y()
614 + fPlanes[3].c*p.
z()+fPlanes[3].d;
615 G4double dist = std::max(dy,std::max(dx1,dx2));
617 return (dist > halfCarTolerance) ?
kOutside :
623 G4double dy = std::max(dz,std::abs(p.
y())+fPlanes[1].d);
624 G4double dx = fPlanes[3].a*std::abs(p.
x())
625 + fPlanes[3].c*p.
z()+fPlanes[3].d;
628 return (dist > halfCarTolerance) ?
kOutside :
634 G4double dy = std::max(dz,std::abs(p.
y())+fPlanes[1].d);
635 G4double dx = fPlanes[3].a*std::abs(p.
x())
636 + fPlanes[3].b*p.
y()+fPlanes[3].d;
639 return (dist > halfCarTolerance) ?
kOutside :
654 nz = std::copysign(
G4double(std::abs(dz) <= halfCarTolerance), p.
z());
660 for (
G4int i=0; i<2; ++i)
662 G4double dy = fPlanes[i].b*p.
y() + fPlanes[i].c*p.
z() + fPlanes[i].d;
663 if (std::abs(dy) > halfCarTolerance) {
continue; }
668 for (
G4int i=2; i<4; ++i)
671 fPlanes[i].b*p.
y() + fPlanes[i].c*p.
z() + fPlanes[i].d;
672 if (std::abs(dx) > halfCarTolerance) {
continue; }
682 G4double dy = std::abs(p.
y()) + fPlanes[1].d;
683 ny = std::copysign(
G4double(std::abs(dy) <= halfCarTolerance), p.
y());
684 for (
G4int i=2; i<4; ++i)
687 fPlanes[i].b*p.
y() + fPlanes[i].c*p.
z() + fPlanes[i].d;
688 if (std::abs(dx) > halfCarTolerance) {
continue; }
698 G4double dy = std::abs(p.
y()) + fPlanes[1].d;
699 ny = std::copysign(
G4double(std::abs(dy) <= halfCarTolerance), p.
y());
700 G4double dx = fPlanes[3].a*std::abs(p.
x()) +
701 fPlanes[3].c*p.
z() + fPlanes[3].d;
703 nx = std::copysign(k, p.
x())*fPlanes[3].a;
704 nz += k*fPlanes[3].c;
709 G4double dy = std::abs(p.
y()) + fPlanes[1].d;
710 ny = std::copysign(
G4double(std::abs(dy) <= halfCarTolerance), p.
y());
711 G4double dx = fPlanes[3].a*std::abs(p.
x()) +
712 fPlanes[3].b*p.
y() + fPlanes[3].d;
714 nx = std::copysign(k, p.
x())*fPlanes[3].a;
715 ny += k*fPlanes[3].b;
722 G4double mag2 = nx*nx + ny*ny + nz*nz;
735 std::ostringstream message;
736 G4long oldprc = message.precision(16);
737 message <<
"Point p is not on surface (!?) of solid: "
739 message <<
"Position:\n";
740 message <<
" p.x() = " << p.
x()/mm <<
" mm\n";
741 message <<
" p.y() = " << p.
y()/mm <<
" mm\n";
742 message <<
" p.z() = " << p.
z()/mm <<
" mm";
743 G4cout.precision(oldprc) ;
744 G4Exception(
"G4Trap::SurfaceNormal(p)",
"GeomSolids1002",
749 return ApproxSurfaceNormal(p);
761 for (
G4int i=0; i<4; ++i)
765 fPlanes[i].
c*p.
z() + fPlanes[i].
d;
766 if (d > dist) { dist = d; iside = i; }
772 return { fPlanes[iside].a, fPlanes[iside].b, fPlanes[iside].c };
775 return { 0, 0, (
G4double)((p.
z() < 0) ? -1 : 1) };
788 if ((std::abs(p.
z()) - fDz) >= -halfCarTolerance && p.
z()*v.
z() >= 0)
793 G4double dz = (invz < 0) ? fDz : -fDz;
803 G4double cosa = fPlanes[i].b*v.
y() + fPlanes[i].c*v.
z();
804 G4double dist = fPlanes[i].b*p.
y() + fPlanes[i].c*p.
z() + fPlanes[i].d;
805 if (dist >= -halfCarTolerance)
807 if (cosa >= 0) {
return kInfinity; }
809 if (tymin < tmp) { tymin = tmp; }
814 if (tymax > tmp) { tymax = tmp; }
823 G4double cosa = fPlanes[i].a*v.
x()+fPlanes[i].b*v.
y()+fPlanes[i].c*v.
z();
824 G4double dist = fPlanes[i].a*p.
x()+fPlanes[i].b*p.
y()+fPlanes[i].c*p.
z() +
826 if (dist >= -halfCarTolerance)
828 if (cosa >= 0) {
return kInfinity; }
830 if (txmin < tmp) { txmin = tmp; }
835 if (txmax > tmp) { txmax = tmp; }
841 G4double tmin = std::max(std::max(txmin,tymin),tzmin);
842 G4double tmax = std::min(std::min(txmax,tymax),tzmax);
844 if (tmax <= tmin + halfCarTolerance) {
return kInfinity; }
846 return (tmin < halfCarTolerance ) ? 0. : tmin;
862 G4double dy1 = fPlanes[0].b*p.
y()+fPlanes[0].c*p.
z()+fPlanes[0].d;
863 G4double dy2 = fPlanes[1].b*p.
y()+fPlanes[1].c*p.
z()+fPlanes[1].d;
864 G4double dy = std::max(dz,std::max(dy1,dy2));
866 G4double dx1 = fPlanes[2].a*p.
x()+fPlanes[2].b*p.
y()
867 + fPlanes[2].c*p.
z()+fPlanes[2].d;
868 G4double dx2 = fPlanes[3].a*p.
x()+fPlanes[3].b*p.
y()
869 + fPlanes[3].c*p.
z()+fPlanes[3].d;
870 G4double dist = std::max(dy,std::max(dx1,dx2));
871 return (dist > 0) ? dist : 0.;
876 G4double dy = std::max(dz,std::abs(p.
y())+fPlanes[1].d);
877 G4double dx1 = fPlanes[2].a*p.
x()+fPlanes[2].b*p.
y()
878 + fPlanes[2].c*p.
z()+fPlanes[2].d;
879 G4double dx2 = fPlanes[3].a*p.
x()+fPlanes[3].b*p.
y()
880 + fPlanes[3].c*p.
z()+fPlanes[3].d;
881 G4double dist = std::max(dy,std::max(dx1,dx2));
882 return (dist > 0) ? dist : 0.;
887 G4double dy = std::max(dz,std::abs(p.
y())+fPlanes[1].d);
888 G4double dx = fPlanes[3].a*std::abs(p.
x())
889 + fPlanes[3].c*p.
z()+fPlanes[3].d;
891 return (dist > 0) ? dist : 0.;
896 G4double dy = std::max(dz,std::abs(p.
y())+fPlanes[1].d);
897 G4double dx = fPlanes[3].a*std::abs(p.
x())
898 + fPlanes[3].b*p.
y()+fPlanes[3].d;
900 return (dist > 0) ? dist : 0.;
918 if ((std::abs(p.
z()) - fDz) >= -halfCarTolerance && p.
z()*v.
z() > 0)
923 n->set(0, 0, (p.
z() < 0) ? -1 : 1);
929 G4int iside = (vz < 0) ? -4 : -2;
936 G4double cosa = fPlanes[i].b*v.
y() + fPlanes[i].c*v.
z();
939 G4double dist = fPlanes[i].b*p.
y() + fPlanes[i].c*p.
z() + fPlanes[i].d;
940 if (dist >= -halfCarTolerance)
945 n->set(0, fPlanes[i].b, fPlanes[i].c);
950 if (tmax > tmp) { tmax = tmp; iside = i; }
958 G4double cosa = fPlanes[i].a*v.
x()+fPlanes[i].b*v.
y()+fPlanes[i].c*v.
z();
962 fPlanes[i].b*p.
y() + fPlanes[i].c*p.
z() + fPlanes[i].d;
963 if (dist >= -halfCarTolerance)
968 n->set(fPlanes[i].a, fPlanes[i].b, fPlanes[i].c);
973 if (tmax > tmp) { tmax = tmp; iside = i; }
984 n->set(0, 0, iside + 3);
988 n->set(fPlanes[iside].a, fPlanes[iside].b, fPlanes[iside].c);
1004 std::ostringstream message;
1005 G4long oldprc = message.precision(16);
1006 message <<
"Point p is outside (!?) of solid: " <<
GetName() <<
G4endl;
1007 message <<
"Position:\n";
1008 message <<
" p.x() = " << p.
x()/mm <<
" mm\n";
1009 message <<
" p.y() = " << p.
y()/mm <<
" mm\n";
1010 message <<
" p.z() = " << p.
z()/mm <<
" mm";
1011 G4cout.precision(oldprc);
1012 G4Exception(
"G4Trap::DistanceToOut(p)",
"GeomSolids1002",
1022 G4double dy1 = fPlanes[0].b*p.
y()+fPlanes[0].c*p.
z()+fPlanes[0].d;
1023 G4double dy2 = fPlanes[1].b*p.
y()+fPlanes[1].c*p.
z()+fPlanes[1].d;
1024 G4double dy = std::max(dz,std::max(dy1,dy2));
1026 G4double dx1 = fPlanes[2].a*p.
x()+fPlanes[2].b*p.
y()
1027 + fPlanes[2].c*p.
z()+fPlanes[2].d;
1028 G4double dx2 = fPlanes[3].a*p.
x()+fPlanes[3].b*p.
y()
1029 + fPlanes[3].c*p.
z()+fPlanes[3].d;
1030 G4double dist = std::max(dy,std::max(dx1,dx2));
1031 return (dist < 0) ? -dist : 0.;
1036 G4double dy = std::max(dz,std::abs(p.
y())+fPlanes[1].d);
1037 G4double dx1 = fPlanes[2].a*p.
x()+fPlanes[2].b*p.
y()
1038 + fPlanes[2].c*p.
z()+fPlanes[2].d;
1039 G4double dx2 = fPlanes[3].a*p.
x()+fPlanes[3].b*p.
y()
1040 + fPlanes[3].c*p.
z()+fPlanes[3].d;
1041 G4double dist = std::max(dy,std::max(dx1,dx2));
1042 return (dist < 0) ? -dist : 0.;
1047 G4double dy = std::max(dz,std::abs(p.
y())+fPlanes[1].d);
1048 G4double dx = fPlanes[3].a*std::abs(p.
x())
1049 + fPlanes[3].c*p.
z()+fPlanes[3].d;
1051 return (dist < 0) ? -dist : 0.;
1056 G4double dy = std::max(dz,std::abs(p.
y())+fPlanes[1].d);
1057 G4double dx = fPlanes[3].a*std::abs(p.
x())
1058 + fPlanes[3].b*p.
y()+fPlanes[3].d;
1060 return (dist < 0) ? -dist : 0.;
1090 return new G4Trap(*
this);
1104 G4long oldprc = os.precision(16);
1105 os <<
"-----------------------------------------------------------\n"
1106 <<
" *** Dump for solid: " <<
GetName() <<
" ***\n"
1107 <<
" ===================================================\n"
1108 <<
" Solid type: G4Trap\n"
1110 <<
" half length Z: " << fDz/mm <<
" mm\n"
1111 <<
" half length Y, face -Dz: " << fDy1/mm <<
" mm\n"
1112 <<
" half length X, face -Dz, side -Dy1: " << fDx1/mm <<
" mm\n"
1113 <<
" half length X, face -Dz, side +Dy1: " << fDx2/mm <<
" mm\n"
1114 <<
" half length Y, face +Dz: " << fDy2/mm <<
" mm\n"
1115 <<
" half length X, face +Dz, side -Dy2: " << fDx3/mm <<
" mm\n"
1116 <<
" half length X, face +Dz, side +Dy2: " << fDx4/mm <<
" mm\n"
1117 <<
" theta: " << theta/degree <<
" degrees\n"
1118 <<
" phi: " << phi/degree <<
" degrees\n"
1119 <<
" alpha, face -Dz: " << alpha1/degree <<
" degrees\n"
1120 <<
" alpha, face +Dz: " <<
alpha2/degree <<
" degrees\n"
1121 <<
"-----------------------------------------------------------\n";
1122 os.precision(oldprc);
1133 for (
G4int i=0; i<8; ++i)
1135 G4int iy = (i==0 || i==1 || i==4 || i==5) ? 0 : 1;
1136 G4int ix = (i==0 || i==2 || i==4 || i==6) ? 2 : 3;
1138 G4double y = -(fPlanes[iy].
c*z + fPlanes[iy].
d)/fPlanes[iy].b;
1139 G4double x = -(fPlanes[ix].
b*y + fPlanes[ix].
c*z
1140 + fPlanes[ix].
d)/fPlanes[ix].a;
1152 constexpr G4int iface [6][4] =
1153 { {0,1,3,2}, {0,4,5,1}, {2,3,7,6}, {0,2,6,4}, {1,5,7,3}, {4,6,7,5} };
1163 k -= (
G4int)(select <= fAreas[4]);
1164 k -= (
G4int)(select <= fAreas[3]);
1165 k -= (
G4int)(select <= fAreas[2]);
1166 k -= (
G4int)(select <= fAreas[1]);
1167 k -= (
G4int)(select <= fAreas[0]);
1171 G4int i0 = iface[k][0];
1172 G4int i1 = iface[k][1];
1173 G4int i2 = iface[k][2];
1174 G4int i3 = iface[k][3];
1176 if (select > fAreas[k] - s2) { i0 = i2; }
1182 if (u + v > 1.) { u = 1. - u; v = 1. - v; }
1183 return (1.-u-v)*pt[i0] + u*pt[i1] + v*pt[i3];
1207 (dx4 + dx3 - dx2 - dx1)*(dy2 - dy1)/3)*dz*0.125;
1223 G4int iface [6][4] =
1224 { {0,1,3,2}, {0,4,5,1}, {2,3,7,6}, {0,2,6,4}, {1,5,7,3}, {4,6,7,5} };
1227 for (
const auto & i : iface)
1250 G4double phi = std::atan2(fTthetaSphi, fTthetaCphi);
1251 G4double alpha1 = std::atan(fTalpha1);
1253 G4double theta = std::atan(std::sqrt(fTthetaCphi*fTthetaCphi
1254 +fTthetaSphi*fTthetaSphi));
1257 fDy1, fDx1, fDx2, alpha1,
1258 fDy2, fDx3, fDx4,
alpha2);
G4TemplateAutoLock< G4Mutex > G4AutoLock
std::vector< G4ThreeVector > G4ThreeVectorList
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4double G4QuickRand(uint32_t seed=0)
#define G4MUTEX_INITIALIZER
CLHEP::Hep3Vector G4ThreeVector
G4GLOB_DLL std::ostream G4cout
void set(double x, double y, double z)
G4BoundingEnvelope is a helper class to facilitate calculation of the extent of a solid within the li...
G4bool BoundingBoxVsVoxelLimits(const EAxis pAxis, const G4VoxelLimits &pVoxelLimits, const G4Transform3D &pTransform3D, G4double &pMin, G4double &pMax) const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimits, const G4Transform3D &pTransform3D, G4double &pMin, G4double &pMax) const
G4bool fRebuildPolyhedron
G4CSGSolid(const G4String &pName)
G4CSGSolid & operator=(const G4CSGSolid &rhs)
G4double GetCubicVolume() override
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep) override
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const override
G4bool IsFaceted() const override
G4GeometryType GetEntityType() const override
void SetAllParameters(G4double pDz, G4double pTheta, G4double pPhi, G4double pDy1, G4double pDx1, G4double pDx2, G4double pAlp1, G4double pDy2, G4double pDx3, G4double pDx4, G4double pAlp2)
G4ThreeVector GetPointOnSurface() const override
G4double GetAlpha2() const
G4double GetAlpha1() const
G4double GetTheta() const
G4VSolid * Clone() const override
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const override
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const override
std::ostream & StreamInfo(std::ostream &os) const override
EInside Inside(const G4ThreeVector &p) const override
G4double GetSurfaceArea() override
G4double GetZHalfLength() const
G4Polyhedron * CreatePolyhedron() const override
G4Trap(const G4String &pName, G4double pDz, G4double pTheta, G4double pPhi, G4double pDy1, G4double pDx1, G4double pDx2, G4double pAlp1, G4double pDy2, G4double pDx3, G4double pDx4, G4double pAlp2)
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const override
G4bool MakePlane(const G4ThreeVector &p1, const G4ThreeVector &p2, const G4ThreeVector &p3, const G4ThreeVector &p4, TrapSidePlane &plane)
void DescribeYourselfTo(G4VGraphicsScene &scene) const override
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const override
G4Trap & operator=(const G4Trap &rhs)
virtual void AddSolid(const G4Box &)=0
G4VPVParameterisation ia an abstract base class for Parameterisation, able to compute the transformat...
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
G4VPhysicalVolume is an abstract base class for the representation of a positioned volume....
G4VSolid(const G4String &name)
G4VoxelLimits represents limitation/restrictions of space, where restrictions are only made perpendic...