Files
geant4/source/geometry/solids/BREPS/include/G4Parabola.icc
T
2016-06-08 16:57:27 +02:00

153 lines
4.3 KiB
Plaintext

//
// ********************************************************************
// * 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: G4Parabola.icc,v 1.6 2001/07/11 09:59:36 gunter Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
// --------------------------------------------------------------------
// GEANT 4 inline definitions file
//
// G4Parabola.icc
//
// Implementation of inline methods of G4Parabola
// --------------------------------------------------------------------
inline
void G4Parabola::Init(const G4Axis2Placement3D& position0,
G4double focalDist0)
{
position= position0;
focalDist= focalDist0;
// focus
F= position.GetLocation()+focalDist*position.GetPX();
// line
L0= position.GetLocation()-focalDist*position.GetPX();
//l= position.GetPY();
}
inline
G4double G4Parabola::GetFocalDist() const
{
return focalDist;
}
//////////////////////////////////////////////////////////////////////////////
inline
G4double G4Parabola::GetPMax() const
{
return -1;
}
inline
G4Point3D G4Parabola::GetPoint(G4double param) const
{
return G4Point3D( position.GetLocation()
+ focalDist* (param*param*position.GetPX()
+ 2*param*position.GetPY()) );
}
inline
G4double G4Parabola::GetPPoint(const G4Point3D& pt) const
{
G4Point3D ptLocal= position.GetToPlacementCoordinates()*pt;
return ptLocal.y()/(2*focalDist);
}
//////////////////////////////////////////////////////////////////////////////
/*
#include "G4CurveRayIntersection.hh"
inline
void G4Parabola::IntersectRay2D(const G4Ray& ray,
G4CurveRayIntersection& is)
{
is.Init(*this, ray);
const G4Point3D& S= ray.GetStart();
const G4Vector3D& d= ray.GetDir();
const G4Vector3D& l= position.GetPY();
// a == 1
G4Vector3D SMinusF= S-F;
G4double bHalf= SMinusF*d - (d.x()*l.y()-d.y()*l.x());
G4double c= SMinusF.mag2() + ( (S.x()-L0.x())*l.y() - (S.y()-L0.y())*l.x() );
G4double discr= bHalf*bHalf-c;
if (discr >= 0) {
// 2 intersections (maybe 1, but this case is rare)
G4double sqrtdiscr= sqrt(discr);
// find the smallest positive i
G4double i= -bHalf-sqrtdiscr;
if (i<kCarTolerance) {
i= -bHalf+sqrtdiscr;
if (i<kCarTolerance) {
return;
}
}
G4CurveRayIntersection isTmp(*this, ray);
isTmp.ResetDistance(i);
is.Update(isTmp);
}
}
*/
inline
G4int G4Parabola::IntersectRay2D(const G4Ray& ray)
{
// NOT VERIFIED
const G4Point3D& S= ray.GetStart();
const G4Vector3D& d= ray.GetDir();
const G4Vector3D& l= position.GetPY();
// a == 1
G4Vector3D SMinusF= G4Vector3D( S-F );
G4double bHalf= SMinusF*d - (d.x()*l.y()-d.y()*l.x());
G4double c= SMinusF.mag2() + ( (S.x()-L0.x())*l.y() - (S.y()-L0.y())*l.x() );
G4int nbinter = 0;
G4double discr= bHalf*bHalf-c;
if (discr >= 0)
{
// 2 intersections (maybe 1, but this case is rare)
G4double sqrtdiscr= sqrt(discr);
G4double i= -bHalf-sqrtdiscr;
if (i>kCarTolerance)
nbinter++;
i= -bHalf+sqrtdiscr;
if (i>kCarTolerance)
nbinter++;
}
return nbinter++;
}