// // ******************************************************************** // * DISCLAIMER * // * * // * The following disclaimer summarizes all the specific disclaimers * // * of contributors to this software. The specific disclaimers,which * // * govern, are listed with their locations in: * // * http://cern.ch/geant4/license * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. * // * * // * This code implementation is the intellectual property of the * // * GEANT4 collaboration. * // * By copying, distributing or modifying the Program (or any work * // * based on the Program) you indicate your acceptance of this * // * statement, and all its terms. * // ******************************************************************** // // // $Id: G4Torus.icc,v 1.1 2002/10/28 11:43:04 gcosmo Exp $ // GEANT4 tag $Name: geant4-05-02-patch-01 $ // // -------------------------------------------------------------------- // GEANT 4 inline definitions file // // G4Torus.icc // // Implementation of inline methods of G4Torus // -------------------------------------------------------------------- inline G4double G4Torus::GetRmin() const { return fRmin ; } inline G4double G4Torus::GetRmax() const { return fRmax ; } inline G4double G4Torus::GetRtor() const { return fRtor ; } inline G4double G4Torus::GetSPhi() const { return fSPhi ; } inline G4double G4Torus::GetDPhi() const { return fDPhi ; } // Utility functions inline G4double G4Torus::TorusEquation (G4double x, G4double y, G4double z, G4double R0, G4double R1) const { // R0 : Radius of all little circles // R1 : Radius of little circles // An interesting property is that the sign // tell if the point is inside or outside // or if > EPSILON on the surface G4double temp; temp = ((x*x + y*y + z*z) + R0*R0 - R1*R1) ; temp = temp*temp ; temp = temp - 4*R0*R0*(x*x + y*y) ; // > 0 Outside // < 0 Inside return temp ; } inline G4double G4Torus::TorusDerivativeX (G4double x, G4double y, G4double z, G4double R0, G4double R1) const { return 4*x*(x*x + y*y + z*z + R0*R0 - R1*R1) - 8*R0*R0*x ; } inline G4double G4Torus::TorusDerivativeY (G4double x, G4double y, G4double z, G4double R0, G4double R1) const { return 4*y*(x*x + y*y + z*z + R0*R0 - R1*R1) - 8*R0*R0*y ; } inline G4double G4Torus::TorusDerivativeZ (G4double x, G4double y, G4double z, G4double R0, G4double R1) const { return 4*z*(x*x + y*y + z*z + R0*R0 - R1*R1) ; } inline G4double G4Torus::TorusGradient(G4double dx, G4double dy, G4double dz, G4double x, G4double y, G4double z, G4double Rmax, G4double Rmin) const { // This tells the normal at a surface point G4double result; result = 0; result += dx*TorusDerivativeX(x,y,z,Rmax,Rmin); result += dy*TorusDerivativeY(x,y,z,Rmax,Rmin); result += dz*TorusDerivativeZ(x,y,z,Rmax,Rmin); return result; } // ----------- G4TorusEquation methods --------------- inline void G4TorusEquation::setRadius (G4double Rmax, G4double Rmin) { R0 = Rmax; R1 = Rmin; } inline void G4TorusEquation::setPosition (G4double x,G4double y,G4double z) { Px = x; Py = y; Pz = z; } inline void G4TorusEquation::setPosition (const G4ThreeVector& p) { Px = p.x(); Py = p.y(); Pz = p.z(); } inline void G4TorusEquation::setDirection (G4double dirx,G4double diry,G4double dirz) { dx = dirx; dy = diry; dz = dirz; } inline void G4TorusEquation::setDirection (const G4ThreeVector& v) { dx = v.x(); dy = v.y(); dz = v.z(); } inline G4double G4TorusEquation::TorusEquation (G4double x, G4double y, G4double z) { // An interesting property is that the sign // tells if the point is inside or outside // or if > EPSILON on the surface G4double temp; temp = ((x*x + y*y + z*z) + R0*R0 - R1*R1) ; temp = temp*temp ; temp = temp - 4*R0*R0*(x*x + y*y) ; // > 0 Outside // < 0 Inside return temp ; } inline G4double G4TorusEquation::TorusDerivativeX (G4double x, G4double y, G4double z) { return 4*x*(x*x + y*y + z*z + R0*R0 - R1*R1) - 8*R0*R0*x ; } inline G4double G4TorusEquation::TorusDerivativeY (G4double x, G4double y, G4double z) { return 4*y*(x*x + y*y + z*z + R0*R0 - R1*R1) - 8*R0*R0*y ; } inline G4double G4TorusEquation::TorusDerivativeZ (G4double x, G4double y, G4double z) { return 4*z*(x*x + y*y + z*z + R0*R0 - R1*R1) ; } inline G4double G4TorusEquation::Function (G4double value) { G4double Lx,Ly,Lz; G4double result; Lx = Px + value*dx; Ly = Py + value*dy; Lz = Pz + value*dz; result = TorusEquation(Lx,Ly,Lz); return result ; } inline G4double G4TorusEquation::Derivative(G4double value) { G4double Lx,Ly,Lz; G4double result; Lx = Px + value*dx; Ly = Py + value*dy; Lz = Pz + value*dz; result = dx*TorusDerivativeX(Lx,Ly,Lz); result += dy*TorusDerivativeY(Lx,Ly,Lz); result += dz*TorusDerivativeZ(Lx,Ly,Lz); return result; }