93 if (leng1 <= delta || leng2 <= delta || leng3 <= delta || leng4 <= delta ||
94 diag1 <= delta || diag2 <= delta)
96 ostringstream message;
97 message <<
"Sides/diagonals of facet are too small." <<
G4endl
102 <<
"Side1 length (P0->P1) = " << leng1 <<
G4endl
103 <<
"Side2 length (P1->P2) = " << leng2 <<
G4endl
104 <<
"Side3 length (P2->P3) = " << leng3 <<
G4endl
105 <<
"Side4 length (P3->P0) = " << leng4 <<
G4endl
106 <<
"Diagonal1 length (P0->P2) = " << diag1 <<
G4endl
107 <<
"Diagonal2 length (P1->P3) = " << diag2;
108 G4Exception(
"G4QuadrangularFacet::G4QuadrangularFacet()",
115 G4double s1 = (e1.cross(e2)).mag()*0.5;
116 G4double s2 = ((e2-e1).cross(e3-e2)).mag()*0.5;
117 G4double s3 = (e2.cross(e3)).mag()*0.5;
118 G4double s4 = (e1.cross(e3)).mag()*0.5;
120 G4double h1 = 2.*s1 / std::max(std::max(leng1,leng2),diag1);
121 G4double h2 = 2.*s2 / std::max(std::max(leng2,leng3),diag2);
122 G4double h3 = 2.*s3 / std::max(std::max(leng3,leng4),diag1);
123 G4double h4 = 2.*s4 / std::max(std::max(leng4,leng1),diag2);
125 if (h1 <= delta || h2 <= delta || h3 <= delta || h4 <= delta )
127 ostringstream message;
128 message <<
"Facet has three or more collinear vertices." <<
G4endl
133 <<
"Smallest heights:" <<
G4endl
134 <<
" in triangle P0-P1-P2 = " << h1 <<
G4endl
135 <<
" in triangle P1-P2-P3 = " << h2 <<
G4endl
136 <<
" in triangle P2-P3-P0 = " << h3 <<
G4endl
137 <<
" in triangle P3-P0-P1 = " << h4;
138 G4Exception(
"G4QuadrangularFacet::G4QuadrangularFacet()",
146 G4double smax = std::max( std::max(s1,s2), std::max(s3,s4) );
147 G4double hmin = 0.5 * std::fabs( e1.dot(e2.cross(e3)) ) / smax;
150 ostringstream message;
151 message <<
"Facet is not planar." <<
G4endl
152 <<
"Disrepancy = " << hmin <<
G4endl
157 G4Exception(
"G4QuadrangularFacet::G4QuadrangularFacet()",
166 G4double s = kInfinity, t = kInfinity, magnitude2 = normal.
mag2();
167 if (magnitude2 > delta*delta)
169 s = normal.
dot(e1.cross(e3-e1)) / magnitude2;
170 t = normal.
dot(e1.cross(e2)) / magnitude2;
172 if (s <= 0. || s >= 1. || t <= 0. || t >= 1.)
174 ostringstream message;
175 message <<
"Facet is not convex." <<
G4endl
176 <<
"Parameters of crosspoint of diagonals: "
177 << s <<
" and " << t <<
G4endl
178 <<
"should both be within (0,1) range" <<
G4endl
183 G4Exception(
"G4QuadrangularFacet::G4QuadrangularFacet()",
193 normal = normal.
unit();
194 fFacet1.SetSurfaceNormal(normal);
195 fFacet2.SetSurfaceNormal(normal);
200 fRadius = std::sqrt(radiusSqr);
305 fFacet1.Intersect(p,v,outgoing,distance,distFromSurface,normal);
306 if (!intersect) intersect =
307 fFacet2.Intersect(p,v,outgoing,distance,distFromSurface,normal);
310 distance = distFromSurface = kInfinity;
G4bool Intersect(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool outgoing, G4double &distance, G4double &distFromSurface, G4ThreeVector &normal) override