56 for (
int i = 0; i < 3; ++i)
fIndices[i] = -1;
60 double eMag3 = (
fE2 -
fE1).Mag();
64 ostringstream message;
65 message <<
"Length of sides of facet are too small." << endl
69 <<
"Side lengths = P[0]->P[1]" << eMag1 << endl
70 <<
"Side lengths = P[0]->P[2]" << eMag2 << endl
71 <<
"Side lengths = P[1]->P[2]" << eMag3;
95 double lambda0 , lambda1 ;
98 ostringstream message;
99 message <<
"Area of Facet is too small, possible flat triangle!" << endl
100 <<
" fVertices[0] = " <<
GetVertex(0) << endl
101 <<
" fVertices[1] = " <<
GetVertex(1) << endl
102 <<
" fVertices[2] = " <<
GetVertex(2) << endl
103 <<
"Area = " <<
fArea;
105 "GeomSolids1001",
UWarning, 1, message.str().c_str());
112 lambda1 = (
fC-
fB) *
fA / (8.0*fArea*fArea);
131 for (
int i = 0; i < 3; ++i)
fIndices[i] = -1;
149 char* p = (
char*) &rhs;
150 copy(p, p +
sizeof(*
this), (
char*)
this);
228 double q =
fB * e -
fC * d;
229 double t =
fB * d -
fA * e;
327 fSqrDist = q * (
fA * q +
fB * t + 2.0 * d) + t * (
fB * q +
fC * t + 2.0 * e) + f;
337 double tmp0 =
fB + d;
338 double tmp1 =
fC + e;
341 double numer = tmp1 - tmp0;
342 double denom =
fA - 2.0 *
fB +
fC;
353 fSqrDist = q * (
fA * q +
fB * t + 2.0 * d) + t * (
fB * q + fC * t + 2.0 * e) + f;
381 double tmp0 =
fB + e;
382 double tmp1 =
fA + d;
385 double numer = tmp1 - tmp0;
386 double denom =
fA - 2.0 *
fB +
fC;
397 fSqrDist = q * (
fA * q +
fB * t + 2.0 * d) + t * (
fB * q + fC * t + 2.0 * e) + f;
425 double numer =
fC + e -
fB - d;
434 double denom =
fA - 2.0 *
fB +
fC;
445 fSqrDist = q * (
fA * q +
fB * t + 2.0 * d) + t * (
fB * q + fC * t + 2.0 * e) + f;
468 double u2 = u.
Mag2();
540 bool wrongSide = (dir > 0.0 && !outgoing) || (dir < 0.0 && outgoing);
547 if (wrongSide) dist = 0.0;
550 else if (!wrongSide) dist = dist1;
566 if (sp > ss) ss =
sp;
568 if (sp > ss) ss =
sp;
623 bool wrongSide = (outgoing && distFromSurface < -0.5 *
kCarTolerance) ||
633 wrongSide = (outgoing && distFromSurface < 0.0) || (!outgoing && distFromSurface > 0.0);
682 UVector2 pprime(p.Dot(mu), p.Dot(nu));
695 double vprimemag = vprime.
mag();
696 double s0 = (loc[0] - pprime).mag() / vprimemag;
697 double s1 = (loc[1] - pprime).mag() / vprimemag;
701 if ((normDist0 < 0.0 && normDist1 < 0.0) || (normDist0 > 0.0 && normDist1 > 0.0) ||
702 (normDist0 == 0.0 && normDist1 == 0.0))
711 double dnormDist = normDist1 - normDist0;
716 if (!outgoing) distFromSurface = -distFromSurface;
721 distance = s0 - normDist0 * (s1 -
s0) / dnormDist;
723 if (!outgoing) distFromSurface = -distFromSurface;
772 distance = distFromSurface / w;
777 double ss =
fB * e -
fC * d;
778 double t =
fB * d -
fA * e;
785 if (ss < -sTolerance || t < -tTolerance || (ss + t -
fDet) > detTolerance)
800 if (!outgoing) distFromSurface = -distFromSurface;
815 double lambda1 = alpha * beta;
816 double lambda0 = alpha - lambda1;
834 return "TriangularFacet";
UTriangularFacet & operator=(const UTriangularFacet &right)
static const double dirTolerance
UVector3 GetPointOnFace() const
UVector3 GetSurfaceNormal() const
void SetSurfaceNormal(UVector3 normal)
UVector3 Cross(const UVector3 &) const
static bool IntersectLineAndTriangle2D(const UVector2 &p, const UVector2 &v, const UVector2 &p0, const UVector2 &e0, const UVector2 &e1, UVector2 location[2])
static double normal(HepRandomEngine *eptr)
void copy(std::vector< T > &main, const std::vector< T > &data)
static const double kInfinity
void CopyFrom(const UTriangularFacet &rhs)
void SetVertex(int i, const UVector3 &val)
double Dot(const UVector3 &) const
UTriangularFacet * GetFlippedFacet()
void Exception(const char *originOfException, const char *exceptionCode, UExceptionSeverity severity, int level, const char *description)
UVector3 GetVertex(int i) const
void Set(double xx, double yy, double zz)
std::vector< UVector3 > * fVertices
std::string UGeometryType
double Extent(const UVector3 axis)
bool Intersect(const UVector3 &p, const UVector3 &v, const bool outgoing, double &distance, double &distFromSurface, UVector3 &normal)
UGeometryType GetEntityType() const
void SetVertices(std::vector< UVector3 > *v)
static const G4double alpha
static const double kCarTolerance
double Random(double min=0.0, double max=1.0)
UVector3 Distance(const UVector3 &p)