27 :
VUSolid(name), fR(r), fCubicVolume(0), fSurfaceArea(0)
29 const double epsilon = 2.e-11;
56 double rad2 = p.
x() * p.
x() + p.
y() * p.
y() + p.
z() * p.
z();
62 double tolRMax2 = tolRMax * tolRMax;
68 tolRMax2 = tolRMax * tolRMax;
95 const double dRmax = 100.*
fR;
99 rad = sqrt(p.
x() * p.
x() + p.
y() * p.
y() + p.
z() * p.
z());
100 pDotV3d = p.
x() * v.
x() + p.
y() * v.
y() + p.
z() * v.
z();
121 c = (rad -
fR) * (rad +
fR);
130 d2 = pDotV3d * pDotV3d - c;
134 s = -pDotV3d - sqrt(d2);
141 double fTerm = s - fmod(s, dRmax);
156 d2 = pDotV3d * pDotV3d - c;
184 ((
UOrb&)*
this).Normal(surfacePoint, normal);
185 double dot = normal.
Dot(v);
186 if (dot > 0)
return 0;
190 double distanceOut =
DistanceToOut(surfacePoint, v, n, convex);
191 return distanceIn + distanceOut;
205 UVector3&
n,
bool& convex,
double )
const
208 bool notOutside =
false;
211 double rad2, pDotV3d;
215 rad2 = p.
x() * p.
x() + p.
y() * p.
y() + p.
z() * p.
z();
216 pDotV3d = p.
x() * v.
x() + p.
y() * v.
y() + p.
z() * v.
z();
235 double rad = sqrt(rad2);
239 c = (rad -
fR) * (rad +
fR);
241 if (c < fRTolerance *
fR)
252 d2 = pDotV3d * pDotV3d - c;
254 if ((c > -2 * fRTolerance * fR) &&
255 ((pDotV3d >= 0) || (d2 < 0)))
269 snxt = -pDotV3d + sqrt(d2);
288 cout <<
"Position:" << endl << endl;
289 cout <<
"p.x() = " << p.
x() << endl;
290 cout <<
"p.y() = " << p.
y() << endl;
291 cout <<
"p.z() = " << p.
z() << endl << endl;
292 cout <<
"Rp = " << sqrt(p.
x() * p.
x() + p.
y() * p.
y() + p.
z() * p.
z()) << endl << endl;
293 cout <<
"Direction:" << endl << endl;
294 cout <<
"v.x() = " << v.
x() << endl;
295 cout <<
"v.y() = " << v.
y() << endl;
296 cout <<
"v.z() = " << v.
z() << endl << endl;
297 cout <<
"Proposed distance :" << endl << endl;
298 cout <<
"snxt = " << snxt << endl << endl;
304 UWarning, 1,
"Logic error: snxt = kInfinity ???");
312 xi = p.
x() + snxt * v.
x();
313 yi = p.
y() + snxt * v.
y();
314 zi = p.
z() + snxt * v.
z();
323 cout <<
"Position:" << endl << endl;
324 cout <<
"p.x() = " << p.
x() <<
" mm" << endl;
325 cout <<
"p.y() = " << p.
y() <<
" mm" << endl;
326 cout <<
"p.z() = " << p.
z() <<
" mm" << endl << endl;
327 cout <<
"Direction:" << endl << endl;
328 cout <<
"v.x() = " << v.
x() << endl;
329 cout <<
"v.y() = " << v.
y() << endl;
330 cout <<
"v.z() = " << v.
z() << endl << endl;
331 cout <<
"Proposed distance :" << endl << endl;
332 cout <<
"snxt = " << snxt <<
" mm" << endl << endl;
337 UWarning, 1,
"Undefined side for valid surface normal to solid.");
359 double safe = 0.0,
rad = sqrt(p.
x() * p.
x() + p.
y() * p.
y() + p.
z() * p.
z());
367 cout <<
"Position:" << endl << endl;
368 cout <<
"p.x = " << p.
x() << endl;
369 cout <<
"p.y = " << p.
y() << endl;
370 cout <<
"p.z = " << p.
z() << endl << endl;
373 "Point p is outside !?");
378 if (safe < 0.) safe = 0.;
398 double rad = sqrt(p.
x() * p.
x() + p.
y() * p.
y() + p.
z() * p.
z());
425 double rad2 = p.
x() * p.
x() + p.
y() * p.
y() + p.
z() * p.
z();
426 double rad = sqrt(rad2);
434 bool result = ((rad2 <= tolRMaxP * tolRMaxP) && (rad2 >= tolRMaxM * tolRMaxM));
458 int oldprc = os.precision(16);
459 os <<
"-----------------------------------------------------------\n"
460 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
461 <<
" ===================================================\n"
462 <<
" Solid type: UOrb\n"
465 <<
" outer radius: " <<
fR <<
" mm \n"
466 <<
"-----------------------------------------------------------\n";
467 os.precision(oldprc);
481 double cosphi = std::cos(phi);
482 double sinphi = std::sin(phi);
486 double sintheta = std::sqrt(1. -
UUtils::sqr(costheta));
488 return UVector3(
fR * sintheta * cosphi,
fR * sintheta * sinphi,
fR * costheta);
493 return new UOrb(*
this);
499 :
VUSolid(rhs), fR(rhs.fR), fRTolerance(rhs.fRTolerance), fCubicVolume(rhs.fCubicVolume), fSurfaceArea(rhs.fSurfaceArea)
518 VUSolid::operator=(rhs);
UOrb & operator=(const UOrb &rhs)
bool Normal(const UVector3 &aPoint, UVector3 &aNormal) const
Return unit normal of surface closest to p.
static double frTolerance
const std::string & GetName() const
static double fgTolerance
std::ostream & StreamInfo(std::ostream &os) const
UGeometryType GetEntityType() const
double DistanceToOutForOutsidePoints(const UVector3 &p, const UVector3 &v, UVector3 &n) const
UVector3 GetPointOnSurface() const
static double normal(HepRandomEngine *eptr)
static const double kInfinity
double SafetyFromInside(const UVector3 &aPoint, bool aAccurate=false) const
double DistanceToIn(const UVector3 &aPoint, const UVector3 &aDirection, double aPstep=UUtils::kInfinity) const
void GetParametersList(int, double *) const
double Dot(const UVector3 &) const
void Extent(UVector3 &aMin, UVector3 &aMax) const
Returns extent of the solid along a given cartesian axis OK.
void Exception(const char *originOfException, const char *exceptionCode, UExceptionSeverity severity, int level, const char *description)
void Set(double xx, double yy, double zz)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
std::string UGeometryType
double SafetyFromOutside(const UVector3 &aPoint, bool aAccurate=false) const
EnumInside Inside(const UVector3 &aPo6int) const
Return whether point inside/outside/on surface Split into radius checks.
double Random(double min=0.0, double max=1.0)
double DistanceToOut(const UVector3 &aPoint, const UVector3 &aDirection, UVector3 &aNormalVector, bool &aConvex, double aPstep=UUtils::kInfinity) const