Logo ROOT  
Reference Guide
TGeoParaboloid.cxx
Go to the documentation of this file.
1 // @(#)root/geom:$Id$
2 // Author: Mihaela Gheata 20/06/04
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 /** \class TGeoParaboloid
13 \ingroup Geometry_classes
14 
15 Paraboloid class.
16 
17 A paraboloid is the solid bounded by the following surfaces:
18  - 2 planes parallel with XY cutting the Z axis at Z=-dz and Z=+dz
19  - the surface of revolution of a parabola described by:
20  `z = a*(x*x + y*y) + b`
21 
22 The parameters a and b are automatically computed from:
23  - rlo - the radius of the circle of intersection between the
24  parabolic surface and the plane z = -dz
25  - rhi - the radius of the circle of intersection between the
26  parabolic surface and the plane z = +dz
27 
28  | -dz = a*rlo*rlo + b
29  | dz = a*rhi*rhi + b where: rlo != rhi, both >= 0
30 */
31 
32 #include <iostream>
33 #include "TGeoManager.h"
34 #include "TGeoVolume.h"
35 #include "TVirtualGeoPainter.h"
36 #include "TGeoParaboloid.h"
37 #include "TBuffer3D.h"
38 #include "TBuffer3DTypes.h"
39 #include "TMath.h"
40 
42 
43 ////////////////////////////////////////////////////////////////////////////////
44 /// Dummy constructor
45 
47 {
48  fRlo = 0;
49  fRhi = 0;
50  fDz = 0;
51  fA = 0;
52  fB = 0;
54 }
55 
56 ////////////////////////////////////////////////////////////////////////////////
57 /// Default constructor specifying X and Y semiaxis length
58 
60  :TGeoBBox(0,0,0)
61 {
62  fRlo = 0;
63  fRhi = 0;
64  fDz = 0;
65  fA = 0;
66  fB = 0;
68  SetParaboloidDimensions(rlo, rhi, dz);
69  ComputeBBox();
70 }
71 
72 ////////////////////////////////////////////////////////////////////////////////
73 /// Default constructor specifying X and Y semiaxis length
74 
76  :TGeoBBox(name, 0, 0, 0)
77 {
78  fRlo = 0;
79  fRhi = 0;
80  fDz = 0;
81  fA = 0;
82  fB = 0;
84  SetParaboloidDimensions(rlo, rhi, dz);
85  ComputeBBox();
86 }
87 
88 ////////////////////////////////////////////////////////////////////////////////
89 /// Default constructor specifying minimum and maximum radius
90 /// - param[0] = rlo
91 /// - param[1] = rhi
92 /// - param[2] = dz
93 
95 {
97  SetDimensions(param);
98  ComputeBBox();
99 }
100 
101 ////////////////////////////////////////////////////////////////////////////////
102 /// destructor
103 
105 {
106 }
107 
108 ////////////////////////////////////////////////////////////////////////////////
109 /// Computes capacity of the shape in [length^3]
110 
112 {
113  Double_t capacity = TMath::Pi()*fDz*(fRlo*fRlo+fRhi*fRhi);
114  return capacity;
115 }
116 
117 ////////////////////////////////////////////////////////////////////////////////
118 /// compute bounding box of the tube
119 
121 {
122  fDX = TMath::Max(fRlo, fRhi);
123  fDY = fDX;
124  fDZ = fDz;
125 }
126 
127 ////////////////////////////////////////////////////////////////////////////////
128 /// Compute normal to closest surface from POINT.
129 
130 void TGeoParaboloid::ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm)
131 {
132  norm[0] = norm[1] = 0.0;
133  if (TMath::Abs(point[2]) > fDz) {
134  norm[2] = TMath::Sign(1., dir[2]);
135  return;
136  }
137  Double_t safz = fDz-TMath::Abs(point[2]);
138  Double_t r = TMath::Sqrt(point[0]*point[0]+point[1]*point[1]);
139  Double_t safr = TMath::Abs(r-TMath::Sqrt((point[2]-fB)/fA));
140  if (safz<safr) {
141  norm[2] = TMath::Sign(1., dir[2]);
142  return;
143  }
144  Double_t talf = -2.*fA*r;
145  Double_t calf = 1./TMath::Sqrt(1.+talf*talf);
146  Double_t salf = talf * calf;
147  Double_t phi = TMath::ATan2(point[1], point[0]);
148 
149  norm[0] = salf*TMath::Cos(phi);
150  norm[1] = salf*TMath::Sin(phi);
151  norm[2] = calf;
152  Double_t ndotd = norm[0]*dir[0]+norm[1]*dir[1]+norm[2]*dir[2];
153  if (ndotd < 0) {
154  norm[0] = -norm[0];
155  norm[1] = -norm[1];
156  norm[2] = -norm[2];
157  }
158 }
159 
160 ////////////////////////////////////////////////////////////////////////////////
161 /// test if point is inside the elliptical tube
162 
164 {
165  if (TMath::Abs(point[2])>fDz) return kFALSE;
166  Double_t aa = fA*(point[2]-fB);
167  if (aa < 0) return kFALSE;
168  Double_t rsq = point[0]*point[0]+point[1]*point[1];
169  if (aa < fA*fA*rsq) return kFALSE;
170  return kTRUE;
171 }
172 
173 ////////////////////////////////////////////////////////////////////////////////
174 /// compute closest distance from point px,py to each vertex
175 
177 {
179  const Int_t numPoints=n*(n+1)+2;
180  return ShapeDistancetoPrimitive(numPoints, px, py);
181 }
182 
183 ////////////////////////////////////////////////////////////////////////////////
184 /// Compute distance from a point to the parabola given by:
185 /// `z = a*rsq + b; rsq = x*x+y*y`
186 
188 {
189  Double_t rsq = point[0]*point[0]+point[1]*point[1];
190  Double_t a = fA * (dir[0]*dir[0] + dir[1]*dir[1]);
191  Double_t b = 2.*fA*(point[0]*dir[0]+point[1]*dir[1])-dir[2];
192  Double_t c = fA*rsq + fB - point[2];
195  if (TMath::Abs(b)<TGeoShape::Tolerance()) return dist; // big
196  dist = -c/b;
197  if (dist < 0) return TGeoShape::Big();
198  return dist; // OK
199  }
200  Double_t ainv = 1./a;
201  Double_t sum = - b*ainv;
202  Double_t prod = c*ainv;
203  Double_t delta = sum*sum - 4.*prod;
204  if (delta<0) return dist; // big
205  delta = TMath::Sqrt(delta);
206  Double_t sone = TMath::Sign(1.,ainv);
207  Int_t i = -1;
208  while (i<2) {
209  dist = 0.5*(sum+i*sone*delta);
210  i += 2;
211  if (dist<0) continue;
212  if (dist<1.E-8) {
213  Double_t talf = -2.*fA*TMath::Sqrt(rsq);
214  Double_t phi = TMath::ATan2(point[1], point[0]);
215  Double_t ndotd = talf*(TMath::Cos(phi)*dir[0]+TMath::Sin(phi)*dir[1])+dir[2];
216  if (!in) ndotd *= -1;
217  if (ndotd<0) return dist;
218  } else return dist;
219  }
220  return TGeoShape::Big();
221 }
222 
223 ////////////////////////////////////////////////////////////////////////////////
224 /// compute distance from inside point to surface of the paraboloid
225 
226 Double_t TGeoParaboloid::DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact, Double_t step, Double_t *safe) const
227 {
228  if (iact<3 && safe) {
229  // compute safe distance
230  *safe = Safety(point, kTRUE);
231  if (iact==0) return TGeoShape::Big();
232  if (iact==1 && step<*safe) return TGeoShape::Big();
233  }
234 
235  Double_t dz = TGeoShape::Big();
236  if (dir[2]<0) {
237  dz = -(point[2]+fDz)/dir[2];
238  } else if (dir[2]>0) {
239  dz = (fDz-point[2])/dir[2];
240  }
241  Double_t dpara = DistToParaboloid(point, dir, kTRUE);
242  return TMath::Min(dz, dpara);
243 }
244 
245 ////////////////////////////////////////////////////////////////////////////////
246 /// compute distance from outside point to surface of the paraboloid and safe distance
247 
248 Double_t TGeoParaboloid::DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact, Double_t step, Double_t *safe) const
249 {
250  if (iact<3 && safe) {
251  // compute safe distance
252  *safe = Safety(point, kFALSE);
253  if (iact==0) return TGeoShape::Big();
254  if (iact==1 && step<*safe) return TGeoShape::Big();
255  }
256  Double_t xnew, ynew, znew;
257  if (point[2]<=-fDz) {
258  if (dir[2]<=0) return TGeoShape::Big();
259  Double_t snxt = -(fDz+point[2])/dir[2];
260  // find extrapolated X and Y
261  xnew = point[0]+snxt*dir[0];
262  ynew = point[1]+snxt*dir[1];
263  if ((xnew*xnew+ynew*ynew) <= fRlo*fRlo) return snxt;
264  } else if (point[2]>=fDz) {
265  if (dir[2]>=0) return TGeoShape::Big();
266  Double_t snxt = (fDz-point[2])/dir[2];
267  // find extrapolated X and Y
268  xnew = point[0]+snxt*dir[0];
269  ynew = point[1]+snxt*dir[1];
270  if ((xnew*xnew+ynew*ynew) <= fRhi*fRhi) return snxt;
271  }
272  Double_t snxt = DistToParaboloid(point, dir, kFALSE);
273  if (snxt > 1E20) return snxt;
274  znew = point[2]+snxt*dir[2];
275  if (TMath::Abs(znew) <= fDz) return snxt;
276  return TGeoShape::Big();
277 }
278 
279 ////////////////////////////////////////////////////////////////////////////////
280 /// Divide the paraboloid along one axis.
281 
282 TGeoVolume *TGeoParaboloid::Divide(TGeoVolume * /*voldiv*/, const char * /*divname*/, Int_t /*iaxis*/, Int_t /*ndiv*/,
283  Double_t /*start*/, Double_t /*step*/)
284 {
285  Error("Divide", "Paraboloid divisions not implemented");
286  return 0;
287 }
288 
289 ////////////////////////////////////////////////////////////////////////////////
290 /// Fill vector param[4] with the bounding cylinder parameters. The order
291 /// is the following : Rmin, Rmax, Phi1, Phi2
292 
294 {
295  param[0] = 0.; // Rmin
296  param[1] = fDX; // Rmax
297  param[1] *= param[1];
298  param[2] = 0.; // Phi1
299  param[3] = 360.; // Phi2
300 }
301 
302 ////////////////////////////////////////////////////////////////////////////////
303 /// in case shape has some negative parameters, these has to be computed
304 /// in order to fit the mother
305 
307 {
308  return 0;
309 }
310 
311 ////////////////////////////////////////////////////////////////////////////////
312 /// print shape parameters
313 
315 {
316  printf("*** Shape %s: TGeoParaboloid ***\n", GetName());
317  printf(" rlo = %11.5f\n", fRlo);
318  printf(" rhi = %11.5f\n", fRhi);
319  printf(" dz = %11.5f\n", fDz);
320  printf(" Bounding box:\n");
322 }
323 
324 ////////////////////////////////////////////////////////////////////////////////
325 /// Creates a TBuffer3D describing *this* shape.
326 /// Coordinates are in local reference frame.
327 
329 {
331  Int_t nbPnts = n*(n+1)+2;
332  Int_t nbSegs = n*(2*n+3);
333  Int_t nbPols = n*(n+2);
334 
336  nbPnts, 3*nbPnts, nbSegs, 3*nbSegs, nbPols, 2*n*5 + n*n*6);
337 
338  if (buff)
339  {
340  SetPoints(buff->fPnts);
341  SetSegsAndPols(*buff);
342  }
343 
344  return buff;
345 }
346 
347 ////////////////////////////////////////////////////////////////////////////////
348 /// Fill TBuffer3D structure for segments and polygons.
349 
351 {
352  Int_t indx, i, j;
354 
355  Int_t c = GetBasicColor();
356 
357  Int_t nn1 = (n+1)*n+1;
358  indx = 0;
359  // Lower end-cap (n radial segments)
360  for (j=0; j<n; j++) {
361  buff.fSegs[indx++] = c+2;
362  buff.fSegs[indx++] = 0;
363  buff.fSegs[indx++] = j+1;
364  }
365  // Sectors (n)
366  for (i=0; i<n+1; i++) {
367  // lateral (circles) segments (n)
368  for (j=0; j<n; j++) {
369  buff.fSegs[indx++] = c;
370  buff.fSegs[indx++] = n*i+1+j;
371  buff.fSegs[indx++] = n*i+1+((j+1)%n);
372  }
373  if (i==n) break; // skip i=n for generators
374  // generator segments (n)
375  for (j=0; j<n; j++) {
376  buff.fSegs[indx++] = c;
377  buff.fSegs[indx++] = n*i+1+j;
378  buff.fSegs[indx++] = n*(i+1)+1+j;
379  }
380  }
381  // Upper end-cap
382  for (j=0; j<n; j++) {
383  buff.fSegs[indx++] = c+1;
384  buff.fSegs[indx++] = n*n+1+j;
385  buff.fSegs[indx++] = nn1;
386  }
387 
388  indx = 0;
389 
390  // lower end-cap (n polygons)
391  for (j=0; j<n; j++) {
392  buff.fPols[indx++] = c+2;
393  buff.fPols[indx++] = 3;
394  buff.fPols[indx++] = n+j;
395  buff.fPols[indx++] = (j+1)%n;
396  buff.fPols[indx++] = j;
397  }
398  // Sectors (n)
399  for (i=0; i<n; i++) {
400  // lateral faces (n)
401  for (j=0; j<n; j++) {
402  buff.fPols[indx++] = c;
403  buff.fPols[indx++] = 4;
404  buff.fPols[indx++] = (2*i+1)*n+j;
405  buff.fPols[indx++] = 2*(i+1)*n+j;
406  buff.fPols[indx++] = (2*i+3)*n+j;
407  buff.fPols[indx++] = 2*(i+1)*n+((j+1)%n);
408  }
409  }
410  // upper end-cap (n polygons)
411  for (j=0; j<n; j++) {
412  buff.fPols[indx++] = c+1;
413  buff.fPols[indx++] = 3;
414  buff.fPols[indx++] = 2*n*(n+1)+j;
415  buff.fPols[indx++] = 2*n*(n+1)+((j+1)%n);
416  buff.fPols[indx++] = (2*n+1)*n+j;
417  }
418 }
419 
420 ////////////////////////////////////////////////////////////////////////////////
421 /// Computes the closest distance from given point to this shape.
422 
424 {
425  Double_t safz = fDz-TMath::Abs(point[2]);
426  if (!in) safz = -safz;
427  Double_t safr;
428  Double_t rsq = point[0]*point[0]+point[1]*point[1];
429  Double_t z0 = fA*rsq+fB;
430  Double_t r0sq = (point[2]-fB)/fA;
431  if (r0sq<0) {
432  if (in) return 0.;
433  return safz;
434  }
435  Double_t dr = TMath::Sqrt(rsq)-TMath::Sqrt(r0sq);
436  if (in) {
437  if (dr>-1.E-8) return 0.;
438  Double_t dz = TMath::Abs(point[2]-z0);
439  safr = -dr*dz/TMath::Sqrt(dr*dr+dz*dz);
440  } else {
441  if (dr<1.E-8) return safz;
442  Double_t talf = -2.*fA*TMath::Sqrt(r0sq);
443  Double_t salf = talf/TMath::Sqrt(1.+talf*talf);
444  safr = TMath::Abs(dr*salf);
445  }
446  if (in) return TMath::Min(safr,safz);
447  return TMath::Max(safr,safz);
448 }
449 
450 ////////////////////////////////////////////////////////////////////////////////
451 /// Set paraboloid dimensions.
452 
454 {
455  if ((rlo<0) || (rhi<0) || (dz<=0) || TMath::Abs(rlo-rhi)<TGeoShape::Tolerance()) {
457  Error("SetParaboloidDimensions", "Dimensions of %s invalid: check (rlo>=0) (rhi>=0) (rlo!=rhi) dz>0",GetName());
458  return;
459  }
460  fRlo = rlo;
461  fRhi = rhi;
462  fDz = dz;
463  Double_t dd = 1./(fRhi*fRhi - fRlo*fRlo);
464  fA = 2.*fDz*dd;
465  fB = - fDz * (fRlo*fRlo + fRhi*fRhi)*dd;
466 }
467 
468 ////////////////////////////////////////////////////////////////////////////////
469 /// Set paraboloid dimensions starting from an array.
470 
472 {
473  Double_t rlo = param[0];
474  Double_t rhi = param[1];
475  Double_t dz = param[2];
476  SetParaboloidDimensions(rlo, rhi, dz);
477 }
478 
479 ////////////////////////////////////////////////////////////////////////////////
480 /// Create paraboloid mesh points.
481 /// ~~~ {.cpp}
482 /// Npoints = n*(n+1) + 2
483 /// ifirst = 0
484 /// ipoint(i,j) = 1+i*n+j; i=[0,n] j=[0,n-1]
485 /// ilast = 1+n*(n+1)
486 /// Nsegments = n*(2*n+3)
487 /// lower: (0, j+1); j=[0,n-1]
488 /// circle(i): (n*i+1+j, n*i+1+(j+1)%n); i=[0,n] j=[0,n-1]
489 /// generator(i): (n*i+1+j, n*(i+1)+1+j); i,j=[0,n-1]
490 /// upper: (n*n+1+j, (n+1)*n+1) j=[0,n-1]
491 /// Npolygons = n*(n+2)
492 /// lower: (n+j, (j+1)%n, j) j=[0,n-1]
493 /// lateral(i): ((2*i+1)*n+j, 2*(i+1)*n+j, (2*i+3)*n+j, 2*(i+1)*n+(j+1)%n)
494 /// i,j = [0,n-1]
495 /// upper: ((2n+1)*n+j, 2*n*(n+1)+(j+1)%n, 2*n*(n+1)+j) j=[0,n-1]
496 /// ~~~
497 
499 {
500  if (!points) return;
501  Double_t ttmin, ttmax;
502  ttmin = TMath::ATan2(-fDz, fRlo);
503  ttmax = TMath::ATan2(fDz, fRhi);
505  Double_t dtt = (ttmax-ttmin)/n;
506  Double_t dphi = 360./n;
507  Double_t tt;
508  Double_t r, z, delta;
509  Double_t phi, sph, cph;
510  Int_t indx = 0;
511  // center of the lower endcap:
512  points[indx++] = 0; // x
513  points[indx++] = 0; // y
514  points[indx++] = -fDz;
515  for (Int_t i=0; i<n+1; i++) { // nz planes = n+1
516  if (i==0) {
517  r = fRlo;
518  z = -fDz;
519  } else if (i==n) {
520  r = fRhi;
521  z = fDz;
522  } else {
523  tt = TMath::Tan(ttmin + i*dtt);
524  delta = tt*tt - 4*fA*fB; // should be always positive (a*b<0)
525  r = 0.5*(tt+TMath::Sqrt(delta))/fA;
526  z = r*tt;
527  }
528  for (Int_t j=0; j<n; j++) {
529  phi = j*dphi*TMath::DegToRad();
530  sph=TMath::Sin(phi);
531  cph=TMath::Cos(phi);
532  points[indx++] = r*cph;
533  points[indx++] = r*sph;
534  points[indx++] = z;
535  }
536  }
537  // center of the upper endcap
538  points[indx++] = 0; // x
539  points[indx++] = 0; // y
540  points[indx++] = fDz;
541 }
542 
543 ////////////////////////////////////////////////////////////////////////////////
544 /// Returns numbers of vertices, segments and polygons composing the shape mesh.
545 
546 void TGeoParaboloid::GetMeshNumbers(Int_t &nvert, Int_t &nsegs, Int_t &npols) const
547 {
549  nvert = n*(n+1)+2;
550  nsegs = n*(2*n+3);
551  npols = n*(n+2);
552 }
553 
554 ////////////////////////////////////////////////////////////////////////////////
555 /// Returns number of vertices on the paraboloid mesh.
556 
558 {
560  return (n*(n+1)+2);
561 }
562 
563 ////////////////////////////////////////////////////////////////////////////////
564 /// Save a primitive as a C++ statement(s) on output stream "out".
565 
566 void TGeoParaboloid::SavePrimitive(std::ostream &out, Option_t * /*option*/ /*= ""*/)
567 {
568  if (TObject::TestBit(kGeoSavePrimitive)) return;
569  out << " // Shape: " << GetName() << " type: " << ClassName() << std::endl;
570  out << " rlo = " << fRlo << ";" << std::endl;
571  out << " rhi = " << fRhi << ";" << std::endl;
572  out << " dz = " << fDZ << ";" << std::endl;
573  out << " TGeoShape *" << GetPointerName() << " = new TGeoParaboloid(\"" << GetName() << "\", rlo,rhi,dz);" << std::endl;
575 }
576 
577 ////////////////////////////////////////////////////////////////////////////////
578 /// Create paraboloid mesh points.
579 
581 {
582  if (!points) return;
583  Double_t ttmin, ttmax;
584  ttmin = TMath::ATan2(-fDz, fRlo);
585  ttmax = TMath::ATan2(fDz, fRhi);
587  Double_t dtt = (ttmax-ttmin)/n;
588  Double_t dphi = 360./n;
589  Double_t tt;
590  Double_t r, z, delta;
591  Double_t phi, sph, cph;
592  Int_t indx = 0;
593  // center of the lower endcap:
594  points[indx++] = 0; // x
595  points[indx++] = 0; // y
596  points[indx++] = -fDz;
597  for (Int_t i=0; i<n+1; i++) { // nz planes = n+1
598  if (i==0) {
599  r = fRlo;
600  z = -fDz;
601  } else if (i==n) {
602  r = fRhi;
603  z = fDz;
604  } else {
605  tt = TMath::Tan(ttmin + i*dtt);
606  delta = tt*tt - 4*fA*fB; // should be always positive (a*b<0)
607  r = 0.5*(tt+TMath::Sqrt(delta))/fA;
608  z = r*tt;
609  }
610  for (Int_t j=0; j<n; j++) {
611  phi = j*dphi*TMath::DegToRad();
612  sph=TMath::Sin(phi);
613  cph=TMath::Cos(phi);
614  points[indx++] = r*cph;
615  points[indx++] = r*sph;
616  points[indx++] = z;
617  }
618  }
619  // center of the upper endcap
620  points[indx++] = 0; // x
621  points[indx++] = 0; // y
622  points[indx++] = fDz;
623 }
624 
625 ////////////////////////////////////////////////////////////////////////////////
627 {
628 }
629 
630 ////////////////////////////////////////////////////////////////////////////////
631 /// Fills a static 3D buffer and returns a reference.
632 
633 const TBuffer3D & TGeoParaboloid::GetBuffer3D(Int_t reqSections, Bool_t localFrame) const
634 {
635  static TBuffer3D buffer(TBuffer3DTypes::kGeneric);
636  TGeoBBox::FillBuffer3D(buffer, reqSections, localFrame);
637 
638  if (reqSections & TBuffer3D::kRawSizes) {
640  Int_t nbPnts = n*(n+1)+2;
641  Int_t nbSegs = n*(2*n+3);
642  Int_t nbPols = n*(n+2);
643  if (buffer.SetRawSizes(nbPnts, 3*nbPnts, nbSegs, 3*nbSegs, nbPols, 2*n*5 + n*n*6)) {
645  }
646  }
647  if ((reqSections & TBuffer3D::kRaw) && buffer.SectionsValid(TBuffer3D::kRawSizes)) {
648  SetPoints(buffer.fPnts);
649  if (!buffer.fLocalFrame) {
650  TransformPoints(buffer.fPnts, buffer.NbPnts());
651  }
652  SetSegsAndPols(buffer);
654  }
655 
656  return buffer;
657 }
658 
659 ////////////////////////////////////////////////////////////////////////////////
660 /// Check the inside status for each of the points in the array.
661 /// Input: Array of point coordinates + vector size
662 /// Output: Array of Booleans for the inside of each point
663 
664 void TGeoParaboloid::Contains_v(const Double_t *points, Bool_t *inside, Int_t vecsize) const
665 {
666  for (Int_t i=0; i<vecsize; i++) inside[i] = Contains(&points[3*i]);
667 }
668 
669 ////////////////////////////////////////////////////////////////////////////////
670 /// Compute the normal for an array o points so that norm.dot.dir is positive
671 /// Input: Arrays of point coordinates and directions + vector size
672 /// Output: Array of normal directions
673 
674 void TGeoParaboloid::ComputeNormal_v(const Double_t *points, const Double_t *dirs, Double_t *norms, Int_t vecsize)
675 {
676  for (Int_t i=0; i<vecsize; i++) ComputeNormal(&points[3*i], &dirs[3*i], &norms[3*i]);
677 }
678 
679 ////////////////////////////////////////////////////////////////////////////////
680 /// Compute distance from array of input points having directions specified by dirs. Store output in dists
681 
682 void TGeoParaboloid::DistFromInside_v(const Double_t *points, const Double_t *dirs, Double_t *dists, Int_t vecsize, Double_t* step) const
683 {
684  for (Int_t i=0; i<vecsize; i++) dists[i] = DistFromInside(&points[3*i], &dirs[3*i], 3, step[i]);
685 }
686 
687 ////////////////////////////////////////////////////////////////////////////////
688 /// Compute distance from array of input points having directions specified by dirs. Store output in dists
689 
690 void TGeoParaboloid::DistFromOutside_v(const Double_t *points, const Double_t *dirs, Double_t *dists, Int_t vecsize, Double_t* step) const
691 {
692  for (Int_t i=0; i<vecsize; i++) dists[i] = DistFromOutside(&points[3*i], &dirs[3*i], 3, step[i]);
693 }
694 
695 ////////////////////////////////////////////////////////////////////////////////
696 /// Compute safe distance from each of the points in the input array.
697 /// Input: Array of point coordinates, array of statuses for these points, size of the arrays
698 /// Output: Safety values
699 
700 void TGeoParaboloid::Safety_v(const Double_t *points, const Bool_t *inside, Double_t *safe, Int_t vecsize) const
701 {
702  for (Int_t i=0; i<vecsize; i++) safe[i] = Safety(&points[3*i], inside[i]);
703 }
c
#define c(i)
Definition: RSha256.hxx:101
n
const Int_t n
Definition: legend1.C:16
TGeoParaboloid::Sizeof3D
virtual void Sizeof3D() const
Definition: TGeoParaboloid.cxx:626
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:100
TGeoParaboloid::InspectShape
virtual void InspectShape() const
print shape parameters
Definition: TGeoParaboloid.cxx:314
tt
auto * tt
Definition: textangle.C:16
TObject::TestBit
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:187
TBuffer3D::SectionsValid
Bool_t SectionsValid(UInt_t mask) const
Definition: TBuffer3D.h:67
TMath::ATan2
Double_t ATan2(Double_t y, Double_t x)
Definition: TMath.h:679
TGeoParaboloid::GetBoundingCylinder
virtual void GetBoundingCylinder(Double_t *param) const
Fill vector param[4] with the bounding cylinder parameters.
Definition: TGeoParaboloid.cxx:293
TGeoParaboloid::DistancetoPrimitive
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
compute closest distance from point px,py to each vertex
Definition: TGeoParaboloid.cxx:176
Option_t
const char Option_t
Definition: RtypesCore.h:66
TBuffer3D::SetSectionsValid
void SetSectionsValid(UInt_t mask)
Definition: TBuffer3D.h:65
TMath::Max
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:212
TGeoParaboloid::Safety
virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const
Computes the closest distance from given point to this shape.
Definition: TGeoParaboloid.cxx:423
TGeoParaboloid::DistFromOutside
virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=0) const
compute distance from outside point to surface of the paraboloid and safe distance
Definition: TGeoParaboloid.cxx:248
TMath::Cos
Double_t Cos(Double_t)
Definition: TMath.h:643
gGeoManager
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:602
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
r
ROOT::R::TRInterface & r
Definition: Object.C:4
sum
static uint64_t sum(uint64_t i)
Definition: Factory.cxx:2345
TObject::Error
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:893
TGeoParaboloid::fA
Double_t fA
Definition: TGeoParaboloid.h:23
TGeoParaboloid::DistFromInside_v
virtual void DistFromInside_v(const Double_t *points, const Double_t *dirs, Double_t *dists, Int_t vecsize, Double_t *step) const
Compute distance from array of input points having directions specified by dirs. Store output in dist...
Definition: TGeoParaboloid.cxx:682
TMath::Sqrt
Double_t Sqrt(Double_t x)
Definition: TMath.h:691
TMath::DegToRad
constexpr Double_t DegToRad()
Conversion from degree to radian:
Definition: TMath.h:81
TMath::Tan
Double_t Tan(Double_t)
Definition: TMath.h:647
TGeoParaboloid::Safety_v
virtual void Safety_v(const Double_t *points, const Bool_t *inside, Double_t *safe, Int_t vecsize) const
Compute safe distance from each of the points in the input array.
Definition: TGeoParaboloid.cxx:700
Float_t
float Float_t
Definition: RtypesCore.h:57
TGeoShape::TransformPoints
void TransformPoints(Double_t *points, UInt_t NbPoints) const
Tranform a set of points (LocalToMaster)
Definition: TGeoShape.cxx:552
TGeoVolume.h
TGeoParaboloid::Divide
virtual TGeoVolume * Divide(TGeoVolume *voldiv, const char *divname, Int_t iaxis, Int_t ndiv, Double_t start, Double_t step)
Divide the paraboloid along one axis.
Definition: TGeoParaboloid.cxx:282
TGeoManager::GetNsegments
Int_t GetNsegments() const
Get number of segments approximating circles.
Definition: TGeoManager.cxx:3351
TBuffer3D::NbPnts
UInt_t NbPnts() const
Definition: TBuffer3D.h:80
TGeoShape::SetShapeBit
void SetShapeBit(UInt_t f, Bool_t set)
Equivalent of TObject::SetBit.
Definition: TGeoShape.cxx:524
TBuffer3D::SetRawSizes
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.
Definition: TBuffer3D.cxx:359
TMath::Abs
Short_t Abs(Short_t d)
Definition: TMathBase.h:120
TGeoParaboloid::~TGeoParaboloid
virtual ~TGeoParaboloid()
destructor
Definition: TGeoParaboloid.cxx:104
TGeoShape::GetBasicColor
Int_t GetBasicColor() const
Get the basic color (0-7).
Definition: TGeoShape.cxx:673
TGeoParaboloid::Contains_v
virtual void Contains_v(const Double_t *points, Bool_t *inside, Int_t vecsize) const
Check the inside status for each of the points in the array.
Definition: TGeoParaboloid.cxx:664
TBuffer3D::fSegs
Int_t * fSegs
Definition: TBuffer3D.h:113
b
#define b(i)
Definition: RSha256.hxx:100
TGeoParaboloid::Capacity
virtual Double_t Capacity() const
Computes capacity of the shape in [length^3].
Definition: TGeoParaboloid.cxx:111
bool
TGeoParaboloid::DistToParaboloid
Double_t DistToParaboloid(const Double_t *point, const Double_t *dir, Bool_t in) const
Compute distance from a point to the parabola given by: z = a*rsq + b; rsq = x*x+y*y
Definition: TGeoParaboloid.cxx:187
TGeoParaboloid::Contains
virtual Bool_t Contains(const Double_t *point) const
test if point is inside the elliptical tube
Definition: TGeoParaboloid.cxx:163
TGeoParaboloid.h
ROOT::Math::gv_detail::dist
double dist(Rotation3D const &r1, Rotation3D const &r2)
Definition: 3DDistances.cxx:48
TGeoParaboloid::DistFromInside
virtual Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=0) const
compute distance from inside point to surface of the paraboloid
Definition: TGeoParaboloid.cxx:226
TBuffer3D
Generic 3D primitive description class.
Definition: TBuffer3D.h:18
TMath::Pi
constexpr Double_t Pi()
Definition: TMath.h:37
TGeoParaboloid::fDz
Double_t fDz
Definition: TGeoParaboloid.h:22
TGeoShape
Base abstract class for all shapes.
Definition: TGeoShape.h:26
TGeoParaboloid::SetParaboloidDimensions
void SetParaboloidDimensions(Double_t rlo, Double_t rhi, Double_t dz)
Set paraboloid dimensions.
Definition: TGeoParaboloid.cxx:453
TGeoShape::kGeoParaboloid
@ kGeoParaboloid
Definition: TGeoShape.h:62
TBuffer3DTypes::kGeneric
@ kGeneric
Definition: TBuffer3DTypes.h:24
TGeoBBox::InspectShape
virtual void InspectShape() const
Prints shape parameters.
Definition: TGeoBBox.cxx:790
TObject::SetBit
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:696
TGeoBBox::fDY
Double_t fDY
Definition: TGeoBBox.h:22
a
auto * a
Definition: textangle.C:12
TGeoParaboloid::SetDimensions
virtual void SetDimensions(Double_t *param)
Set paraboloid dimensions starting from an array.
Definition: TGeoParaboloid.cxx:471
TBuffer3D.h
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:101
TMath::Sign
T1 Sign(T1 a, T2 b)
Definition: TMathBase.h:165
TGeoParaboloid::ComputeNormal_v
virtual void ComputeNormal_v(const Double_t *points, const Double_t *dirs, Double_t *norms, Int_t vecsize)
Compute the normal for an array o points so that norm.dot.dir is positive Input: Arrays of point coor...
Definition: TGeoParaboloid.cxx:674
TGeoShape::kGeoSavePrimitive
@ kGeoSavePrimitive
Definition: TGeoShape.h:65
TBuffer3DTypes.h
TMath::Sin
Double_t Sin(Double_t)
Definition: TMath.h:639
TGeoShape::kGeoRunTimeShape
@ kGeoRunTimeShape
Definition: TGeoShape.h:41
TBuffer3D::kRaw
@ kRaw
Definition: TBuffer3D.h:54
TGeoShape::GetName
virtual const char * GetName() const
Get the shape name.
Definition: TGeoShape.cxx:248
TGeoBBox
Box class.
Definition: TGeoBBox.h:18
TGeoParaboloid::GetMakeRuntimeShape
virtual TGeoShape * GetMakeRuntimeShape(TGeoShape *mother, TGeoMatrix *mat) const
in case shape has some negative parameters, these has to be computed in order to fit the mother
Definition: TGeoParaboloid.cxx:306
TGeoParaboloid::SetSegsAndPols
virtual void SetSegsAndPols(TBuffer3D &buff) const
Fill TBuffer3D structure for segments and polygons.
Definition: TGeoParaboloid.cxx:350
TGeoBBox::FillBuffer3D
virtual void FillBuffer3D(TBuffer3D &buffer, Int_t reqSections, Bool_t localFrame) const
Fills the supplied buffer, with sections in desired frame See TBuffer3D.h for explanation of sections...
Definition: TGeoBBox.cxx:1030
TMath::Min
Short_t Min(Short_t a, Short_t b)
Definition: TMathBase.h:180
TGeoParaboloid::fRhi
Double_t fRhi
Definition: TGeoParaboloid.h:21
TGeoParaboloid::fRlo
Double_t fRlo
Definition: TGeoParaboloid.h:20
TGeoManager.h
TGeoBBox::fDZ
Double_t fDZ
Definition: TGeoBBox.h:23
TGeoParaboloid
Paraboloid class.
Definition: TGeoParaboloid.h:18
TGeoShape::GetPointerName
const char * GetPointerName() const
Provide a pointer name containing uid.
Definition: TGeoShape.cxx:699
TVirtualGeoPainter.h
Double_t
double Double_t
Definition: RtypesCore.h:59
TGeoMatrix
Geometrical transformation package.
Definition: TGeoMatrix.h:41
TBuffer3D::fLocalFrame
Bool_t fLocalFrame
Definition: TBuffer3D.h:90
TGeoParaboloid::GetBuffer3D
virtual const TBuffer3D & GetBuffer3D(Int_t reqSections, Bool_t localFrame) const
Fills a static 3D buffer and returns a reference.
Definition: TGeoParaboloid.cxx:633
points
point * points
Definition: X3DBuffer.c:22
TGeoParaboloid::fB
Double_t fB
Definition: TGeoParaboloid.h:24
TGeoParaboloid::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TGeoParaboloid.cxx:566
TBuffer3D::kRawSizes
@ kRawSizes
Definition: TBuffer3D.h:53
name
char name[80]
Definition: TGX11.cxx:110
TGeoShape::ShapeDistancetoPrimitive
Int_t ShapeDistancetoPrimitive(Int_t numpoints, Int_t px, Int_t py) const
Returns distance to shape primitive mesh.
Definition: TGeoShape.cxx:259
TBuffer3D::fPnts
Double_t * fPnts
Definition: TBuffer3D.h:112
TGeoShape::Tolerance
static Double_t Tolerance()
Definition: TGeoShape.h:91
TGeoParaboloid::GetMeshNumbers
virtual void GetMeshNumbers(Int_t &nvert, Int_t &nsegs, Int_t &npols) const
Returns numbers of vertices, segments and polygons composing the shape mesh.
Definition: TGeoParaboloid.cxx:546
TGeoParaboloid::ComputeNormal
virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm)
Compute normal to closest surface from POINT.
Definition: TGeoParaboloid.cxx:130
TGeoShape::Big
static Double_t Big()
Definition: TGeoShape.h:88
TGeoParaboloid::MakeBuffer3D
virtual TBuffer3D * MakeBuffer3D() const
Creates a TBuffer3D describing this shape.
Definition: TGeoParaboloid.cxx:328
TGeoParaboloid::GetNmeshVertices
virtual Int_t GetNmeshVertices() const
Returns number of vertices on the paraboloid mesh.
Definition: TGeoParaboloid.cxx:557
TBuffer3D::fPols
Int_t * fPols
Definition: TBuffer3D.h:114
TGeoParaboloid::DistFromOutside_v
virtual void DistFromOutside_v(const Double_t *points, const Double_t *dirs, Double_t *dists, Int_t vecsize, Double_t *step) const
Compute distance from array of input points having directions specified by dirs. Store output in dist...
Definition: TGeoParaboloid.cxx:690
TObject::ClassName
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:130
TGeoVolume
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition: TGeoVolume.h:49
TGeoBBox::fDX
Double_t fDX
Definition: TGeoBBox.h:21
TGeoParaboloid::TGeoParaboloid
TGeoParaboloid()
Dummy constructor.
Definition: TGeoParaboloid.cxx:46
TMath.h
TGeoParaboloid::SetPoints
virtual void SetPoints(Double_t *points) const
Create paraboloid mesh points.
Definition: TGeoParaboloid.cxx:498
int
TGeoParaboloid::ComputeBBox
virtual void ComputeBBox()
compute bounding box of the tube
Definition: TGeoParaboloid.cxx:120