92 if (leng1 <= delta || leng2 <= delta || leng3 <= delta || leng4 <= delta ||
93 diag1 <= delta || diag2 <= delta)
95 ostringstream message;
96 message <<
"Sides/diagonals of facet are too small." <<
G4endl
101 <<
"Side1 length (P0->P1) = " << leng1 <<
G4endl
102 <<
"Side2 length (P1->P2) = " << leng2 <<
G4endl
103 <<
"Side3 length (P2->P3) = " << leng3 <<
G4endl
104 <<
"Side4 length (P3->P0) = " << leng4 <<
G4endl
105 <<
"Diagonal1 length (P0->P2) = " << diag1 <<
G4endl
106 <<
"Diagonal2 length (P1->P3) = " << diag2;
107 G4Exception(
"G4QuadrangularFacet::G4QuadrangularFacet()",
114 G4double s1 = (e1.cross(e2)).mag()*0.5;
115 G4double s2 = ((e2-e1).cross(e3-e2)).mag()*0.5;
116 G4double s3 = (e2.cross(e3)).mag()*0.5;
117 G4double s4 = (e1.cross(e3)).mag()*0.5;
119 G4double h1 = 2.*s1 / std::max(std::max(leng1,leng2),diag1);
120 G4double h2 = 2.*s2 / std::max(std::max(leng2,leng3),diag2);
121 G4double h3 = 2.*s3 / std::max(std::max(leng3,leng4),diag1);
122 G4double h4 = 2.*s4 / std::max(std::max(leng4,leng1),diag2);
124 if (h1 <= delta || h2 <= delta || h3 <= delta || h4 <= delta )
126 ostringstream message;
127 message <<
"Facet has three or more collinear vertices." <<
G4endl
132 <<
"Smallest heights:" <<
G4endl
133 <<
" in triangle P0-P1-P2 = " << h1 <<
G4endl
134 <<
" in triangle P1-P2-P3 = " << h2 <<
G4endl
135 <<
" in triangle P2-P3-P0 = " << h3 <<
G4endl
136 <<
" in triangle P3-P0-P1 = " << h4;
137 G4Exception(
"G4QuadrangularFacet::G4QuadrangularFacet()",
145 G4double smax = std::max( std::max(s1,s2), std::max(s3,s4) );
146 G4double hmin = 0.5 * std::fabs( e1.dot(e2.cross(e3)) ) / smax;
149 ostringstream message;
150 message <<
"Facet is not planar." <<
G4endl
151 <<
"Disrepancy = " << hmin <<
G4endl
156 G4Exception(
"G4QuadrangularFacet::G4QuadrangularFacet()",
165 G4double s = kInfinity, t = kInfinity, magnitude2 = normal.
mag2();
166 if (magnitude2 > delta*delta)
168 s = normal.
dot(e1.cross(e3-e1)) / magnitude2;
169 t = normal.
dot(e1.cross(e2)) / magnitude2;
171 if (s <= 0. || s >= 1. || t <= 0. || t >= 1.)
173 ostringstream message;
174 message <<
"Facet is not convex." <<
G4endl
175 <<
"Parameters of crosspoint of diagonals: "
176 << s <<
" and " << t <<
G4endl
177 <<
"should both be within (0,1) range" <<
G4endl
182 G4Exception(
"G4QuadrangularFacet::G4QuadrangularFacet()",
192 normal = normal.
unit();
193 fFacet1.SetSurfaceNormal(normal);
194 fFacet2.SetSurfaceNormal(normal);
199 fRadius = std::sqrt(radiusSqr);
307 fFacet1.Intersect(p,v,outgoing,distance,distFromSurface,normal);
310 intersect = fFacet2.Intersect(p,v,outgoing,distance,distFromSurface,normal);
314 distance = distFromSurface = kInfinity;
G4bool Intersect(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool outgoing, G4double &distance, G4double &distFromSurface, G4ThreeVector &normal) override