// // ******************************************************************** // * 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: G4Hyperbola.icc,v 1.9 2006/06/29 18:39:38 gunter Exp $ // GEANT4 tag $Name: geant4-09-04-beta-01 $ // // -------------------------------------------------------------------- // GEANT 4 inline definitions file // // G4Hyperbola.icc // // Implementation of inline methods of G4Hyperbola // -------------------------------------------------------------------- inline void G4Hyperbola::Init(G4Axis2Placement3D position0, G4double semiAxis0, G4double semiImagAxis0) { position= position0; semiAxis= semiAxis0; semiImagAxis= semiImagAxis0; ratioAxisImagAxis= semiAxis/semiImagAxis; // needed only for 2D hyperbolas toUnitHyperbola = G4Scale3D(1/semiAxis, 1/semiImagAxis, 0) * position.GetToPlacementCoordinates(); forTangent= semiAxis*semiAxis/(semiImagAxis*semiImagAxis); } inline G4double G4Hyperbola::GetSemiAxis() const { return semiAxis; } inline G4double G4Hyperbola::GetSemiImagAxis() const { return semiImagAxis; } ////////////////////////////////////////////////////////////////////////////// inline G4double G4Hyperbola::GetPMax() const { return -1; } inline G4Point3D G4Hyperbola::GetPoint(G4double param) const { return G4Point3D( position.GetLocation() + semiAxis*std::cosh(param)*position.GetPX() + semiImagAxis*std::sinh(param)*position.GetPY() ); } inline G4double G4Hyperbola::GetPPoint(const G4Point3D& pt) const { G4Point3D ptLocal= position.GetToPlacementCoordinates()*pt; G4double xval= ptLocal.y()/ptLocal.x()*ratioAxisImagAxis; return 0.5*std::log((1+xval)/(1-xval)); // atanh(xval) } ///////////////////////////////////////////////////////////////////////////// /* #include "G4CurveRayIntersection.hh" inline void G4Hyperbola::IntersectRay2D(const G4Ray& ray, G4CurveRayIntersection& is) { is.Init(*this, ray); // similar to G4Ellipse::IntersectRay2D // 2D operations would be faster G4Point3D s= toUnitHyperbola*ray.GetStart(); G4Vector3D d= toUnitHyperbola*ray.GetDir(); // solve (s+i*t)^2 = 1 for i (the distance) G4double sd= s.x()*d.x()-s.y()*d.y(); G4double dd= d.x()*d.x()-d.y()*d.y(); // can be 0 G4double ss= s.x()*s.x()-s.y()*s.y(); if (std::abs(dd) < kCarTolerance*kCarTolerance) { // coeff of i^2 == 0 G4double i= (1-ss)/(2*sd); G4CurveRayIntersection isTmp(*this, ray); isTmp.ResetDistance(i); is.Update(isTmp); return; } G4double discr= sd*sd-dd*(ss-1); if (discr >= 0) { // 2 intersections (maybe 1, but this case is rare) G4double sqrtdiscr= std::sqrt(discr); // find the smallest positive i G4double i= -sd-sqrtdiscr; if (i= 0) { // 2 intersections (maybe 1, but this case is rare) G4double sqrtdiscr= std::sqrt(discr); // find the smallest positive i G4double i= -sd-sqrtdiscr; if (i > kCarTolerance) nbinter++; i= -sd+sqrtdiscr; if (i