129 norm[0] = norm[1] = 0;
134 norm[0] = point[0] *
b *
b;
135 norm[1] = point[1] *
a *
a;
158 const Int_t numPoints = 4 *
n;
173 if (iact < 3 && safe) {
185 for (
Int_t i = 0; i < 8; i++) {
187 x3 = 0.5 * (
x1 +
x2);
191 y3 = 0.5 * (
y1 +
y2);
197 d2 = (
x2 - x0) * (
x2 - x0) + (
y2 - y0) * (
y2 - y0);
201 d1 = (
x1 - x0) * (
x1 - x0) + (
y1 - y0) * (
y1 - y0);
208 if ((iact == 1) && (*safe > step))
215 snxt = safz1 / dir[2];
218 snxt = -safz2 / dir[2];
221 Double_t xz = point[0] + dir[0] * sz;
222 Double_t yz = point[1] + dir[1] * sz;
223 if ((xz * xz / a2 + yz * yz / b2) <= 1)
227 Double_t u = dir[0] * dir[0] * b2 + dir[1] * dir[1] * a2;
228 Double_t v = point[0] * dir[0] * b2 + point[1] * dir[1] * a2;
229 Double_t w = point[0] * point[0] * b2 + point[1] * point[1] * a2 - a2 * b2;
234 snxt = (-
v + sd) / u;
250 if (iact < 3 && safe) {
254 if ((x0 * x0 / a2 + y0 * y0 / b2) >= 1) {
259 for (
Int_t i = 0; i < 10; i++) {
260 phi3 = (phi1 + phi2) * 0.5;
263 d = y3 * a2 * (x0 - x3) - x3 * b2 * (y0 - y3);
269 *safe =
TMath::Sqrt((x0 - x3) * (x0 - x3) + (y0 - y3) * (y0 - y3));
272 *safe =
TMath::Sqrt((*safe) * (*safe) + safz * safz);
276 if ((iact == 1) && (step < *safe))
285 if (point[2] * dir[2] > 0)
291 zi = (point[2] > 0) ?
fDz : -
fDz;
293 tau = (zi - point[2]) / dir[2];
295 Double_t xz = point[0] + dir[0] * tau;
296 Double_t yz = point[1] + dir[1] * tau;
297 if ((xz * xz / a2 + yz * yz / b2) < 1)
305 Double_t u = dir[0] * dir[0] * b2 + dir[1] * dir[1] * a2;
308 Double_t v = point[0] * dir[0] * b2 + point[1] * dir[1] * a2;
309 Double_t w = point[0] * point[0] * b2 + point[1] * point[1] * a2 - a2 * b2;
316 tau = (-
v + dsq) / u;
320 tau = (-
v - dsq) / u;
321 zi = point[2] + tau * dir[2];
338 Error(
"Divide",
"Elliptical tubes divisions not implemented");
350 param[1] *= param[1];
364 Error(
"GetMakeRuntimeShape",
"invalid mother");
386 printf(
"*** Shape %s: TGeoEltu ***\n",
GetName());
387 printf(
" A = %11.5f\n",
fRmin);
388 printf(
" B = %11.5f\n",
fRmax);
389 printf(
" dz = %11.5f\n",
fDz);
390 printf(
" Bounding box:\n");
410 else if (sqdist < onemin)
441 safr = (dx * bct + dy * ast) /
d;
456 out <<
" a = " <<
fRmin <<
";" << std::endl;
457 out <<
" b = " <<
fRmax <<
";" << std::endl;
458 out <<
" dz = " <<
fDz <<
";" << std::endl;
459 out <<
" TGeoShape *" <<
GetPointerName() <<
" = new TGeoEltu(\"" <<
GetName() <<
"\",a,b,dz);" << std::endl;
468 if ((
a <= 0) || (
b < 0) || (dz < 0)) {
507 for (j = 0; j <
n; j++) {
516 for (j = 0; j <
n; j++) {
520 r2 = (a2 * b2) / (b2 + (a2 - b2) * sph * sph);
569 for (j = 0; j <
n; j++) {
578 for (j = 0; j <
n; j++) {
582 r2 = (a2 * b2) / (b2 + (a2 - b2) * sph * sph);
608 if (buffer.
SetRawSizes(nbPnts, 3 * nbPnts, nbSegs, 3 * nbSegs, nbPols, 6 * nbPols)) {
631 for (
Int_t i = 0; i < vecsize; i++)
642 for (
Int_t i = 0; i < vecsize; i++)
652 for (
Int_t i = 0; i < vecsize; i++)
662 for (
Int_t i = 0; i < vecsize; i++)
673 for (
Int_t i = 0; i < vecsize; i++)
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t points
Option_t Option_t TPoint TPoint const char y1
R__EXTERN TGeoManager * gGeoManager
Generic 3D primitive description class.
Bool_t SectionsValid(UInt_t mask) const
void SetSectionsValid(UInt_t mask)
Bool_t SetRawSizes(UInt_t reqPnts, UInt_t reqPntsCapacity, UInt_t reqSegs, UInt_t reqSegsCapacity, UInt_t reqPols, UInt_t reqPolsCapacity)
Set kRaw tessellation section of buffer with supplied sizes.
void FillBuffer3D(TBuffer3D &buffer, Int_t reqSections, Bool_t localFrame) const override
Fills the supplied buffer, with sections in desired frame See TBuffer3D.h for explanation of sections...
Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=nullptr) const override
Compute distance from outside point to surface of the box.
void InspectShape() const override
Prints shape parameters.
An elliptical tube is defined by the two semi-axes A and B.
void ComputeBBox() override
compute bounding box of the tube
void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm) override
Compute normal to closest surface from POINT.
void Safety_v(const Double_t *points, const Bool_t *inside, Double_t *safe, Int_t vecsize) const override
Compute safe distance from each of the points in the input array.
void SetDimensions(Double_t *param) override
Set shape dimensions starting from an array.
void DistFromInside_v(const Double_t *points, const Double_t *dirs, Double_t *dists, Int_t vecsize, Double_t *step) const override
Compute distance from array of input points having directions specified by dirs. Store output in dist...
void GetMeshNumbers(Int_t &nvert, Int_t &nsegs, Int_t &npols) const override
Returns numbers of vertices, segments and polygons composing the shape mesh.
void SetPoints(Double_t *points) const override
Create elliptical tube mesh points.
~TGeoEltu() override
destructor
Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=nullptr) const override
compute distance from outside point to surface of the tube and safe distance
Double_t Capacity() const override
Computes capacity of the shape in [length^3].
TGeoEltu()
Dummy constructor.
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
compute closest distance from point px,py to each vertex
void ComputeNormal_v(const Double_t *points, const Double_t *dirs, Double_t *norms, Int_t vecsize) override
Compute the normal for an array o points so that norm.dot.dir is positive Input: Arrays of point coor...
TGeoShape * GetMakeRuntimeShape(TGeoShape *mother, TGeoMatrix *mat) const override
in case shape has some negative parameters, these has to be computed in order to fit the mother
void DistFromOutside_v(const Double_t *points, const Double_t *dirs, Double_t *dists, Int_t vecsize, Double_t *step) const override
Compute distance from array of input points having directions specified by dirs. Store output in dist...
Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=nullptr) const override
compute distance from inside point to surface of the tube
void GetBoundingCylinder(Double_t *param) const override
Fill vector param[4] with the bounding cylinder parameters.
const TBuffer3D & GetBuffer3D(Int_t reqSections, Bool_t localFrame) const override
Fills a static 3D buffer and returns a reference.
Int_t GetNmeshVertices() const override
Returns the number of vertices on the mesh.
void SetEltuDimensions(Double_t a, Double_t b, Double_t dz)
Set dimensions of the elliptical tube.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a primitive as a C++ statement(s) on output stream "out".
void InspectShape() const override
print shape parameters
TGeoVolume * Divide(TGeoVolume *voldiv, const char *divname, Int_t iaxis, Int_t ndiv, Double_t start, Double_t step) override
Divide the shape along one axis.
Bool_t Contains(const Double_t *point) const override
test if point is inside the elliptical tube
void Contains_v(const Double_t *points, Bool_t *inside, Int_t vecsize) const override
Check the inside status for each of the points in the array.
Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const override
computes the closest distance from given point to this shape, according to option.
Int_t GetNsegments() const
Get number of segments approximating circles.
Geometrical transformation package.
Base abstract class for all shapes.
void TransformPoints(Double_t *points, UInt_t NbPoints) const
Tranform a set of points (LocalToMaster)
void SetShapeBit(UInt_t f, Bool_t set)
Equivalent of TObject::SetBit.
static Bool_t IsSameWithinTolerance(Double_t a, Double_t b)
Check if two numbers differ with less than a tolerance.
const char * GetPointerName() const
Provide a pointer name containing uid.
Int_t ShapeDistancetoPrimitive(Int_t numpoints, Int_t px, Int_t py) const
Returns distance to shape primitive mesh.
const char * GetName() const override
Get the shape name.
static Double_t Tolerance()
Bool_t TestShapeBit(UInt_t f) const
Int_t GetNmeshVertices() const override
Return number of vertices of the mesh representation.
void GetMeshNumbers(Int_t &nvert, Int_t &nsegs, Int_t &npols) const override
Returns numbers of vertices, segments and polygons composing the shape mesh.
void SetSegsAndPols(TBuffer3D &buff) const override
Fill TBuffer3D structure for segments and polygons.
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
virtual void SetName(const char *name)
Set the name of the TNamed.
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual const char * ClassName() const
Returns name of class to which the object belongs.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Float_t Normalize(Float_t v[3])
Normalize a vector v in place.
T1 Sign(T1 a, T2 b)
Returns a value with the magnitude of a and the sign of b.
constexpr Double_t DegToRad()
Conversion from degree to radian: .
Double_t Sqrt(Double_t x)
Returns the square root of x.
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.