#include <UOrb.hh>
|
| UOrb () |
|
| UOrb (const std::string &name, double pRmax) |
|
| ~UOrb () |
|
| UOrb (const UOrb &rhs) |
|
UOrb & | operator= (const UOrb &rhs) |
|
double | GetRadius () const |
|
void | SetRadius (double newRmax) |
|
EnumInside | Inside (const UVector3 &aPo6int) const |
|
double | SafetyFromInside (const UVector3 &aPoint, bool aAccurate=false) const |
|
double | SafetyFromOutside (const UVector3 &aPoint, bool aAccurate=false) const |
|
double | DistanceToIn (const UVector3 &aPoint, const UVector3 &aDirection, double aPstep=UUtils::kInfinity) const |
|
double | DistanceToOut (const UVector3 &aPoint, const UVector3 &aDirection, UVector3 &aNormalVector, bool &aConvex, double aPstep=UUtils::kInfinity) const |
|
bool | Normal (const UVector3 &aPoint, UVector3 &aNormal) const |
|
void | Extent (UVector3 &aMin, UVector3 &aMax) const |
|
double | Capacity () |
|
double | SurfaceArea () |
|
UGeometryType | GetEntityType () const |
|
void | ComputeBBox (UBBox *, bool) |
|
void | GetParametersList (int, double *) const |
|
VUSolid * | Clone () const |
|
double | GetRadialTolerance () |
|
UVector3 | GetPointOnSurface () const |
|
std::ostream & | StreamInfo (std::ostream &os) const |
|
| VUSolid () |
|
| VUSolid (const std::string &name) |
|
virtual | ~VUSolid () |
|
double | GetCarTolerance () const |
|
double | GetRadTolerance () const |
|
double | GetAngTolerance () const |
|
void | SetCarTolerance (double eps) |
|
void | SetRadTolerance (double eps) |
|
void | SetAngTolerance (double eps) |
|
virtual void | ExtentAxis (EAxisType aAxis, double &aMin, double &aMax) const |
|
const std::string & | GetName () const |
|
void | SetName (const std::string &aName) |
|
virtual void | SamplePointsInside (int, UVector3 *) const |
|
virtual void | SamplePointsOnSurface (int, UVector3 *) const |
|
virtual void | SamplePointsOnEdge (int, UVector3 *) const |
|
double | EstimateCubicVolume (int nStat, double epsilon) const |
|
double | EstimateSurfaceArea (int nStat, double ell) const |
|
Definition at line 28 of file UOrb.hh.
UOrb::UOrb |
( |
const std::string & |
name, |
|
|
double |
pRmax |
|
) |
| |
Definition at line 26 of file UOrb.cc.
References UUtils::Exception(), FatalErrorInArguments, VUSolid::fgTolerance, VUSolid::frTolerance, and G4INCL::Math::max().
27 :
VUSolid(
name), fR(r), fCubicVolume(0), fSurfaceArea(0)
29 const double epsilon = 2.e-11;
static double frTolerance
static double fgTolerance
T max(const T t1, const T t2)
brief Return the largest of the two arguments
void Exception(const char *originOfException, const char *exceptionCode, ExceptionSeverity severity, int level, const char *description)
UOrb::UOrb |
( |
const UOrb & |
rhs | ) |
|
Definition at line 496 of file UOrb.cc.
497 :
VUSolid(rhs), fR(rhs.fR), fRTolerance(rhs.fRTolerance), fCubicVolume(rhs.fCubicVolume), fSurfaceArea(rhs.fSurfaceArea)
double UOrb::Capacity |
( |
| ) |
|
|
inlinevirtual |
Implements VUSolid.
Definition at line 102 of file UOrb.hh.
104 if (fCubicVolume != 0.)
110 fCubicVolume = (4 * UUtils::kPi / 3) * fR * fR * fR;
double UOrb::DistanceToIn |
( |
const UVector3 & |
aPoint, |
|
|
const UVector3 & |
aDirection, |
|
|
double |
aPstep = UUtils::kInfinity |
|
) |
| const |
|
virtual |
Implements VUSolid.
Definition at line 84 of file UOrb.cc.
References test::c, UUtils::Exception(), python.hepunit::rad, Warning, UVector3::x, UVector3::y, and UVector3::z.
89 double snxt = UUtils::kInfinity;
92 double c, d2,
s = UUtils::kInfinity;
94 const double dRmax = 100.*fR;
98 rad = sqrt(
p.x *
p.x +
p.y *
p.y +
p.z *
p.z);
99 pDotV3d =
p.x *
v.x +
p.y *
v.y +
p.z *
v.z;
120 c = (rad - fR) * (rad + fR);
122 if (rad > fR - fRTolerance * 0.5)
124 if (c > fRTolerance * fR)
129 d2 = pDotV3d * pDotV3d -
c;
133 s = -pDotV3d - sqrt(d2);
140 double fTerm = s - fmod(s, dRmax);
148 return snxt = UUtils::kInfinity;
153 if (c > -fRTolerance * fR)
155 d2 = pDotV3d * pDotV3d -
c;
156 if ((d2 < fRTolerance * fR) || (pDotV3d >= 0))
158 return snxt = UUtils::kInfinity;
double DistanceToIn(const UVector3 &aPoint, const UVector3 &aDirection, double aPstep=UUtils::kInfinity) const
void Exception(const char *originOfException, const char *exceptionCode, ExceptionSeverity severity, int level, const char *description)
double UOrb::DistanceToOut |
( |
const UVector3 & |
aPoint, |
|
|
const UVector3 & |
aDirection, |
|
|
UVector3 & |
aNormalVector, |
|
|
bool & |
aConvex, |
|
|
double |
aPstep = UUtils::kInfinity |
|
) |
| const |
|
virtual |
Implements VUSolid.
Definition at line 203 of file UOrb.cc.
References test::c, UUtils::Exception(), python.hepunit::rad, Warning, UVector3::x, UVector3::y, and UVector3::z.
207 bool notOutside =
false;
210 double rad2, pDotV3d;
214 rad2 =
p.x *
p.x +
p.y *
p.y +
p.z *
p.z;
215 pDotV3d =
p.x *
v.x +
p.y *
v.y +
p.z *
v.z;
233 const double rPlus = fR + fRTolerance;
234 double rad = sqrt(rad2);
238 c = (rad - fR) * (rad + fR);
240 if (c < fRTolerance * fR)
251 d2 = pDotV3d * pDotV3d -
c;
253 if ((c > -2 * fRTolerance * fR) &&
254 ((pDotV3d >= 0) || (d2 < 0)))
268 snxt = -pDotV3d + sqrt(d2);
287 cout <<
"Position:" << endl << endl;
288 cout <<
"p.x() = " <<
p.x << endl;
289 cout <<
"p.y() = " <<
p.y << endl;
290 cout <<
"p.z() = " <<
p.z << endl << endl;
291 cout <<
"Rp = " << sqrt(
p.x *
p.x +
p.y *
p.y +
p.z *
p.z) << endl << endl;
292 cout <<
"Direction:" << endl << endl;
293 cout <<
"v.x() = " <<
v.x << endl;
294 cout <<
"v.y() = " <<
v.y << endl;
295 cout <<
"v.z() = " <<
v.z << endl << endl;
296 cout <<
"Proposed distance :" << endl << endl;
297 cout <<
"snxt = " << snxt << endl << endl;
303 Warning, 1,
"Logic error: snxt = kInfinity ???");
311 xi =
p.x + snxt *
v.x;
312 yi =
p.y + snxt *
v.y;
313 zi =
p.z + snxt *
v.z;
322 cout <<
"Position:" << endl << endl;
323 cout <<
"p.x() = " <<
p.x <<
" mm" << endl;
324 cout <<
"p.y() = " <<
p.y <<
" mm" << endl;
325 cout <<
"p.z() = " <<
p.z <<
" mm" << endl << endl;
326 cout <<
"Direction:" << endl << endl;
327 cout <<
"v.x() = " <<
v.x << endl;
328 cout <<
"v.y() = " <<
v.y << endl;
329 cout <<
"v.z() = " <<
v.z << endl << endl;
330 cout <<
"Proposed distance :" << endl << endl;
331 cout <<
"snxt = " << snxt <<
" mm" << endl << endl;
335 UUtils::Exception(
"UOrb::DistanceToOut(p,v,..)",
"Notification",
Warning, 1,
"Undefined side for valid surface normal to solid.");
void Exception(const char *originOfException, const char *exceptionCode, ExceptionSeverity severity, int level, const char *description)
Returns extent of the solid along a given cartesian axis OK
Implements VUSolid.
Definition at line 443 of file UOrb.cc.
References UVector3::Set().
void Set(double xx, double yy, double zz)
void UOrb::GetParametersList |
( |
int |
, |
|
|
double * |
aArray |
|
) |
| const |
|
virtual |
UVector3 UOrb::GetPointOnSurface |
( |
| ) |
const |
|
virtual |
Implements VUSolid.
Definition at line 474 of file UOrb.cc.
References UUtils::Random(), and UUtils::sqr().
479 double cosphi = std::cos(phi);
480 double sinphi = std::sin(phi);
484 double sintheta = std::sqrt(1. -
UUtils::sqr(costheta));
486 return UVector3(fR * sintheta * cosphi, fR * sintheta * sinphi, fR * costheta);
double Random(double min=0.0, double max=1.0)
double UOrb::GetRadialTolerance |
( |
| ) |
|
|
inline |
double UOrb::GetRadius |
( |
| ) |
const |
|
inline |
Return whether point inside/outside/on surface Split into radius checks
Classify point location with respect to solid: o eInside - inside the solid o eSurface - close to surface within tolerance o eOutside - outside the solid
Implements VUSolid.
Definition at line 53 of file UOrb.cc.
References VUSolid::eInside, VUSolid::eOutside, VUSolid::eSurface, UVector3::x, UVector3::y, and UVector3::z.
Referenced by SafetyFromInside().
55 double rad2 = p.
x * p.
x + p.
y * p.
y + p.
z * p.
z;
58 double tolRMax = fR - fRTolerance * 0.5;
61 double tolRMax2 = tolRMax * tolRMax;
66 tolRMax = fR + fRTolerance * 0.5;
67 tolRMax2 = tolRMax * tolRMax;
Return unit normal of surface closest to p
From http://lists.trolltech.com/qt-interest/2002-09/thread01124-0.html :
does anybody here have an algorithm to calculate the normal vector in a given point in space (x, y, z) in a sphere? I know that it's not about qt but i'll like very mutch the help.
It's simply the connecting vector from the centre of the sphere to the point (other way around for inward normals) obtained through vector subtraction, normalized to unity.
You really should get an algebra book though, as you are bound to encounter more of these problems in a 3d application.
Implements VUSolid.
Definition at line 421 of file UOrb.cc.
References python.hepunit::rad, UVector3::x, UVector3::y, and UVector3::z.
423 double rad2 = p.
x * p.
x + p.
y * p.
y + p.
z * p.
z;
424 double rad = sqrt(rad2);
428 double tolRMaxP = fR + fRTolerance;
429 double tolRMaxM = fR - fRTolerance;
432 bool result = ((rad2 <= tolRMaxP * tolRMaxP) && (rad2 >= tolRMaxM * tolRMaxM));
UOrb & UOrb::operator= |
( |
const UOrb & |
rhs | ) |
|
Definition at line 505 of file UOrb.cc.
516 VUSolid::operator=(rhs);
521 fRTolerance = rhs.fRTolerance;
522 fCubicVolume = rhs.fCubicVolume;
523 fSurfaceArea = rhs.fSurfaceArea;
double UOrb::SafetyFromInside |
( |
const UVector3 & |
aPoint, |
|
|
bool |
aAccurate = false |
|
) |
| const |
|
virtual |
Implements VUSolid.
Definition at line 350 of file UOrb.cc.
References UUtils::Exception(), Inside(), kOutside, python.hepunit::rad, Warning, UVector3::x, UVector3::y, and UVector3::z.
357 double safe = 0.0,
rad = sqrt(
p.x *
p.x +
p.y *
p.y +
p.z *
p.z);
365 cout <<
"Position:" << endl << endl;
366 cout <<
"p.x = " <<
p.x << endl;
367 cout <<
"p.y = " <<
p.y << endl;
368 cout <<
"p.z = " <<
p.z << endl << endl;
371 "Point p is outside !?");
376 if (safe < 0.) safe = 0.;
void Exception(const char *originOfException, const char *exceptionCode, ExceptionSeverity severity, int level, const char *description)
EnumInside Inside(const UVector3 &aPo6int) const
double UOrb::SafetyFromOutside |
( |
const UVector3 & |
aPoint, |
|
|
bool |
aAccurate = false |
|
) |
| const |
|
virtual |
void UOrb::SetRadius |
( |
double |
newRmax | ) |
|
|
inline |
std::ostream & UOrb::StreamInfo |
( |
std::ostream & |
os | ) |
const |
|
virtual |
Implements VUSolid.
Definition at line 454 of file UOrb.cc.
References VUSolid::GetName().
456 int oldprc = os.precision(16);
457 os <<
"-----------------------------------------------------------\n"
458 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
459 <<
" ===================================================\n"
460 <<
" Solid type: UOrb\n"
463 <<
" outer radius: " << fR <<
" mm \n"
464 <<
"-----------------------------------------------------------\n";
465 os.precision(oldprc);
const std::string & GetName() const
double UOrb::SurfaceArea |
( |
| ) |
|
|
inlinevirtual |
Implements VUSolid.
Definition at line 115 of file UOrb.hh.
117 if (fSurfaceArea != 0.)
123 fSurfaceArea = (4 * UUtils::kPi) * fR * fR;
The documentation for this class was generated from the following files: