Files
geant4/source/geometry/solids/BREPS/include/G4Parabola.icc
T
2016-06-09 15:37:50 +02:00

156 lines
4.6 KiB
Plaintext

//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4Parabola.icc,v 1.8 2006/06/29 18:39:57 gunter Exp $
// GEANT4 tag $Name: geant4-09-01 $
//
// --------------------------------------------------------------------
// 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= std::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= std::sqrt(discr);
G4double i= -bHalf-sqrtdiscr;
if (i>kCarTolerance)
nbinter++;
i= -bHalf+sqrtdiscr;
if (i>kCarTolerance)
nbinter++;
}
return nbinter++;
}