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 <<
"Height in P0-P1-P2 = " << h1 <<
G4endl
135 <<
"Height in P1-P2-P3 = " << h2 <<
G4endl
136 <<
"Height in P2-P3-P4 = " << h3 <<
G4endl
137 <<
"Height in P4-P0-P1 = " << h4;
138 G4Exception(
"G4QuadrangularFacet::G4QuadrangularFacet()",
146 G4double smax = std::max( std::max(s1,s2), std::max(s3,s4) );
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();
200 fRadius = std::sqrt(radiusSqr);
218 fFacet1 = rhs.fFacet1;
219 fFacet2 = rhs.fFacet2;
228 if (
this == &rhs)
return *
this;
230 fFacet1 = rhs.fFacet1;
231 fFacet2 = rhs.fFacet2;
254 if (v1.
mag2() < v2.
mag2())
return v1;
290 for (
G4int i = 0; i <= 3; ++i)
293 if (sp > ss) ss = sp;
308 fFacet1.
Intersect(p,v,outgoing,distance,distFromSurface,normal);
309 if (!intersect) intersect =
310 fFacet2.
Intersect(p,v,outgoing,distance,distFromSurface,normal);
313 distance = distFromSurface = kInfinity;
345 return "G4QuadrangularFacet";
double epsilon(double density, double 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