// // ******************************************************************** // * 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: G4Ellipse.icc,v 1.5.4.1 2001/06/28 19:08:44 gunter Exp $ // GEANT4 tag $Name: $ // // -------------------------------------------------------------------- // GEANT 4 inline definitions file // // G4Ellipse.icc // // Implementation of inline methods of G4Ellipse // -------------------------------------------------------------------- inline void G4Ellipse::Init(const G4Axis2Placement3D& position0, G4double semiAxis10, G4double semiAxis20) { position= position0; semiAxis1= semiAxis10; semiAxis2= semiAxis20; ratioAxis2Axis1= semiAxis2/semiAxis1; SetBounds(0, 0); // needed only for 2D ellipses toUnitCircle = G4Scale3D(1/semiAxis1, 1/semiAxis2, 0) * position.GetToPlacementCoordinates(); forTangent= -semiAxis1*semiAxis1/(semiAxis2*semiAxis2); } inline G4double G4Ellipse::GetSemiAxis1() const { return semiAxis1; } inline G4double G4Ellipse::GetSemiAxis2() const { return semiAxis2; } ///////////////////////////////////////////////////////////////////////////// inline G4double G4Ellipse::GetPMax() const { return twopi; } inline G4Point3D G4Ellipse::GetPoint(G4double param) const { param-= GetPShift(); return G4Point3D( position.GetLocation() + semiAxis1*cos(param)*position.GetPX() + semiAxis2*sin(param)*position.GetPY() ); } inline G4double G4Ellipse::GetPPoint(const G4Point3D& pt) const { G4Point3D ptLocal= position.GetToPlacementCoordinates()*pt; G4double angle= atan2(ptLocal.y(), ptLocal.x()*ratioAxis2Axis1); G4double r= (angle<0)? angle+twopi: angle; return r+GetPShift(); } ///////////////////////////////////////////////////////////////////////////// #include "G4CurveRayIntersection.hh" /* inline void G4Ellipse::IntersectRay2D(const G4Ray& ray, G4CurveRayIntersection& is) { is.Init(*this, ray); // transform s.t. the ellipse becomes the unit circle // with the center at the origin // 2D operations would be faster G4Point3D s= toUnitCircle*ray.GetStart(); G4Vector3D d= toUnitCircle*ray.GetDir(); // solve (s+i*t)^2 = 1 for i (the distance) G4double sd= s*d; G4double dd= d.mag2(); // never 0 G4double ss= s.mag2(); G4double discr= sd*sd-dd*(ss-1); if (discr >= 0) { // 2 intersections (maybe 1, but this case is rare) G4double sqrtdiscr= sqrt(discr); // find the smallest positive i G4double i= -sd-sqrtdiscr; if (i 0) { // 2 intersections G4double sqrtdiscr= sqrt(discr); // if i is positive, we have an intersection i= -sd-sqrtdiscr; if (i > kCarTolerance) nbinter++; i= -sd+sqrtdiscr; if (i > kCarTolerance) nbinter++; } // if the ray is tangent on the circle if (discr == 0) nbinter = 1; return nbinter; }