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 lambda1 = (
fC -
fB) *
fA / (8.0 * fArea * fArea);
112 for (
int i = 0; i < 3; ++i)
fIndices[i] = -1;
130 char* p = (
char*) &rhs;
131 copy(p, p +
sizeof(*
this), (
char*)
this);
209 double q =
fB * e -
fC * d;
210 double t =
fB * d -
fA * e;
308 fSqrDist = q * (
fA * q +
fB * t + 2.0 * d) + t * (
fB * q +
fC * t + 2.0 * e) + f;
318 double tmp0 =
fB + d;
319 double tmp1 =
fC + e;
322 double numer = tmp1 - tmp0;
323 double denom =
fA - 2.0 *
fB +
fC;
334 fSqrDist = q * (
fA * q +
fB * t + 2.0 * d) + t * (
fB * q + fC * t + 2.0 * e) + f;
362 double tmp0 =
fB + e;
363 double tmp1 =
fA + d;
366 double numer = tmp1 - tmp0;
367 double denom =
fA - 2.0 *
fB +
fC;
378 fSqrDist = q * (
fA * q +
fB * t + 2.0 * d) + t * (
fB * q + fC * t + 2.0 * e) + f;
406 double numer =
fC + e -
fB - d;
415 double denom =
fA - 2.0 *
fB +
fC;
426 fSqrDist = q * (
fA * q +
fB * t + 2.0 * d) + t * (
fB * q + fC * t + 2.0 * e) + f;
449 double u2 = u.
Mag2();
521 bool wrongSide = (dir > 0.0 && !outgoing) || (dir < 0.0 && outgoing);
528 if (wrongSide) dist = 0.0;
531 else if (!wrongSide) dist = dist1;
547 if (sp > ss) ss =
sp;
549 if (sp > ss) ss =
sp;
604 bool wrongSide = (outgoing && distFromSurface < -0.5 *
kCarTolerance) ||
614 wrongSide = (outgoing && distFromSurface < 0.0) || (!outgoing && distFromSurface > 0.0);
663 UVector2 pprime(p.Dot(mu), p.Dot(nu));
676 double vprimemag = vprime.
mag();
677 double s0 = (loc[0] - pprime).mag() / vprimemag;
678 double s1 = (loc[1] - pprime).mag() / vprimemag;
682 if ((normDist0 < 0.0 && normDist1 < 0.0) || (normDist0 > 0.0 && normDist1 > 0.0) ||
683 (normDist0 == 0.0 && normDist1 == 0.0))
692 double dnormDist = normDist1 - normDist0;
697 if (!outgoing) distFromSurface = -distFromSurface;
702 distance = s0 - normDist0 * (s1 -
s0) / dnormDist;
704 if (!outgoing) distFromSurface = -distFromSurface;
753 distance = distFromSurface / w;
758 double ss =
fB * e -
fC * d;
759 double t =
fB * d -
fA * e;
766 if (ss < -sTolerance || t < -tTolerance || (ss + t -
fDet) > detTolerance)
781 if (!outgoing) distFromSurface = -distFromSurface;
796 double lambda1 = alpha * beta;
797 double lambda0 = alpha - lambda1;
815 return "UTriangularFacet";
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()
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)
void Exception(const char *originOfException, const char *exceptionCode, ExceptionSeverity severity, int level, const char *description)
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)