40 : MinRadius(0.), MaxRadius(0.), TransMatrix(0), EQN_EPS(1e-9)
51 Placement.
Init(Dir, Ax, Location);
73 Origin.
z()-MaxRadius);
76 Origin.
z()+MaxRadius);
96 return ((Dist - MaxRadius)*(Dist - MaxRadius));
147 G4double rnorm = MaxRadius - MinRadius;
148 rho = MinRadius*MinRadius / (rnorm*rnorm);
149 a0 = 4. * MaxRadius*MaxRadius;
150 b0 = MaxRadius*MaxRadius - MinRadius*MinRadius;
153 f = 1. - DCos.
y()*DCos.
y();
154 l = 2. * (Base.
x()*DCos.
x() + Base.
z()*DCos.
z());
155 t = Base.
x()*Base.
x() + Base.
z()*Base.
z();
156 g1 = f + rho * DCos.
y()*DCos.
y();
158 m1 = (l + 2.*rho*DCos.
y()*Base.
y()) / g1;
159 u = (t + rho*Base.
y()*Base.
y() + b0) / g1;
165 C[2] = m1*m1 + 2.*u - q*f;
166 C[1] = 2.*m1*u - q*l;
170 nhits = SolveQuartic (C,rhits);
173 m1 = rhits[0]; u = rhits[1]; rhits[0] = u; rhits[1] = m1;
174 m1 = rhits[2]; u = rhits[3]; rhits[2] = u; rhits[3] = m1;
203 for(
G4int a=0;a<nhits;a++)
205 while ( (c1 < 4) && (hits[c1] <= rhits[a]) )
207 tempVec[c1]=hits[c1];
211 for(c2=c1+1;c2<4;c2++)
212 tempVec[c2]=hits[c2-1];
216 tempVec[c1]=rhits[a];
219 hits[c2]=tempVec[c2];
223 for(
G4int b=0;b<nhits;b++)
228 Hit = Base + (hits[b]*DCos);
230 if( (Hit.
x() > BoxMin.
x()) &&
231 (Hit.
x() < BoxMax.
x()) &&
232 (Hit.
y() > BoxMin.
y()) &&
233 (Hit.
y() < BoxMax.
y()) &&
234 (Hit.
z() > BoxMin.
z()) &&
235 (Hit.
z() < BoxMax.
z()) )
278 A = cc[ 3 ] / cc[ 4 ];
279 B = cc[ 2 ] / cc[ 4 ];
280 C = cc[ 1 ] / cc[ 4 ];
281 D = cc[ 0 ] / cc[ 4 ];
287 p = - 3.0/8 * sq_A + B;
288 q = 1.0/8 * sq_A * A - 1.0/2 * A * B + C;
289 r = - 3.0/256*sq_A*sq_A + 1.0/16*sq_A*B - 1.0/4*A*C + D;
300 num = SolveCubic(coeffs, ss);
307 coeffs[ 0 ] = 1.0/2 * r * p - 1.0/8 * q * q;
309 coeffs[ 2 ] = - 1.0/2 * p;
312 (void) SolveCubic(coeffs, ss);
336 coeffs[ 1 ] = q < 0 ? -v : v;
339 num = SolveQuadric(coeffs, ss);
342 coeffs[ 1 ] = q < 0 ? v : -v;
345 num += SolveQuadric(coeffs, ss + num);
352 for (i = 0; i < num; ++i)
369 A = cc[ 2 ] / cc[ 3 ];
370 B = cc[ 1 ] / cc[ 3 ];
371 C = cc[ 0 ] / cc[ 3 ];
376 p = 1.0/3 * (- 1.0/3 * sq_A + B);
377 q = 1.0/2 * (2.0/27 * A * sq_A - 1.0/3 * A * B + C);
400 G4double phi = 1.0/3 * std::acos(-q / std::sqrt(-cb_p));
403 ss[ 0 ] = t * std::cos(phi);
404 ss[ 1 ] = - t * std::cos(phi + pi / 3);
405 ss[ 2 ] = - t * std::cos(phi - pi / 3);
411 G4double u = std::pow(sqrt_D - q,1./3.);
412 G4double v = - std::pow(sqrt_D + q,1./3.);
421 for (i = 0; i < num; ++i)
434 p = cc[ 1 ] / (2 * cc[ 2 ]);
435 q = cc[ 0 ] / cc[ 2 ];
452 ss[ 0 ] = sqrt_D - p;
453 ss[ 1 ] = - sqrt_D - p;
HepGeom::Vector3D< G4double > G4Vector3D
void Init(const G4Vector3D &refDirection0, const G4Vector3D &axis0, const G4Point3D &location0)
G4Point3D GetLocation() const
G4Point3D GetBoxMin() const
G4Point3D GetBoxMax() const
const G4Vector3D & GetDir() const
const G4Point3D & GetStart() const
G4int Intersect(const G4Ray &)
G4double ClosestDistanceToPoint(const G4Point3D &x)
virtual ~G4ToroidalSurface()
virtual G4Vector3D SurfaceNormal(const G4Point3D &Pt) const