94 if (leng1 <= delta || leng2 <= delta || leng3 <= delta || leng4 <= delta ||
95 diag1 <= delta || diag2 <= delta)
97 ostringstream message;
98 message <<
"Sides/diagonals of facet are too small." <<
G4endl
103 <<
"Side1 length (P0->P1) = " << leng1 <<
G4endl
104 <<
"Side2 length (P1->P2) = " << leng2 <<
G4endl
105 <<
"Side3 length (P2->P3) = " << leng3 <<
G4endl
106 <<
"Side4 length (P3->P0) = " << leng4 <<
G4endl
107 <<
"Diagonal1 length (P0->P2) = " << diag1 <<
G4endl
108 <<
"Diagonal2 length (P1->P3) = " << diag2;
109 G4Exception(
"G4QuadrangularFacet::G4QuadrangularFacet()",
117 G4double s2 = ((e2-e1).cross(e3-e2)).mag()*0.5;
121 G4double h1 = 2.*s1 / std::max(std::max(leng1,leng2),diag1);
122 G4double h2 = 2.*s2 / std::max(std::max(leng2,leng3),diag2);
123 G4double h3 = 2.*s3 / std::max(std::max(leng3,leng4),diag1);
124 G4double h4 = 2.*s4 / std::max(std::max(leng4,leng1),diag2);
126 if (h1 <= delta || h2 <= delta || h3 <= delta || h4 <= delta )
128 ostringstream message;
129 message <<
"Facet has three or more collinear vertices." <<
G4endl
134 <<
"Smallest heights:" <<
G4endl
135 <<
" in triangle P0-P1-P2 = " << h1 <<
G4endl
136 <<
" in triangle P1-P2-P3 = " << h2 <<
G4endl
137 <<
" in triangle P2-P3-P0 = " << h3 <<
G4endl
138 <<
" in triangle P3-P0-P1 = " << h4;
139 G4Exception(
"G4QuadrangularFacet::G4QuadrangularFacet()",
147 G4double smax = std::max( std::max(s1,s2), std::max(s3,s4) );
151 ostringstream message;
152 message <<
"Facet is not planar." <<
G4endl
153 <<
"Disrepancy = " << hmin <<
G4endl
158 G4Exception(
"G4QuadrangularFacet::G4QuadrangularFacet()",
167 G4double s = kInfinity, t = kInfinity, magnitude2 = normal.
mag2();
168 if (magnitude2 > delta*delta)
170 s = normal.
dot(e1.
cross(e3-e1)) / magnitude2;
171 t = normal.
dot(e1.
cross(e2)) / magnitude2;
173 if (s <= 0. || s >= 1. || t <= 0. || t >= 1.)
175 ostringstream message;
176 message <<
"Facet is not convex." <<
G4endl
177 <<
"Parameters of crosspoint of diagonals: "
178 << s <<
" and " << t <<
G4endl
179 <<
"should both be within (0,1) range" <<
G4endl
184 G4Exception(
"G4QuadrangularFacet::G4QuadrangularFacet()",
194 normal = normal.
unit();
201 fRadius = std::sqrt(radiusSqr);
219 fFacet1 = rhs.fFacet1;
220 fFacet2 = rhs.fFacet2;
229 if (
this == &rhs)
return *
this;
231 fFacet1 = rhs.fFacet1;
232 fFacet2 = rhs.fFacet2;
255 if (v1.
mag2() < v2.
mag2())
return v1;
291 for (
G4int i = 0; i <= 3; ++i)
294 if (sp > ss) ss = sp;
309 fFacet1.
Intersect(p,v,outgoing,distance,distFromSurface,normal);
310 if (!intersect) intersect =
311 fFacet2.
Intersect(p,v,outgoing,distance,distFromSurface,normal);
314 distance = distFromSurface = kInfinity;
346 return "G4QuadrangularFacet";
G4double epsilon(G4double density, G4double temperature)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Hep3Vector cross(const Hep3Vector &) const
double dot(const Hep3Vector &) const
void set(double x, double y, double z)
G4ThreeVector Distance(const G4ThreeVector &p)
G4bool Intersect(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool outgoing, G4double &distance, G4double &distFromSurface, G4ThreeVector &normal)
G4QuadrangularFacet(const G4ThreeVector &Pt0, const G4ThreeVector &vt1, const G4ThreeVector &vt2, const G4ThreeVector &vt3, G4FacetVertexType)
void SetVertex(G4int i, const G4ThreeVector &val)
G4ThreeVector GetSurfaceNormal() const
G4QuadrangularFacet & operator=(const G4QuadrangularFacet &right)
G4ThreeVector GetVertex(G4int i) const
G4GeometryType GetEntityType() const
G4double Extent(const G4ThreeVector axis)
G4ThreeVector GetPointOnFace() const
void SetSurfaceNormal(G4ThreeVector normal)
G4ThreeVector GetPointOnFace() const
G4bool Intersect(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool outgoing, G4double &distance, G4double &distFromSurface, G4ThreeVector &normal)
G4ThreeVector Distance(const G4ThreeVector &p)
G4ThreeVector GetSurfaceNormal() const
static const G4double dirTolerance