source: trunk/source/geometry/solids/BREPS/include/G4Parabola.icc@ 1036

Last change on this file since 1036 was 850, checked in by garnier, 17 years ago

geant4.8.2 beta

File size: 4.6 KB
RevLine 
[831]1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27// $Id: G4Parabola.icc,v 1.8 2006/06/29 18:39:57 gunter Exp $
[850]28// GEANT4 tag $Name: HEAD $
[831]29//
30// --------------------------------------------------------------------
31// GEANT 4 inline definitions file
32//
33// G4Parabola.icc
34//
35// Implementation of inline methods of G4Parabola
36// --------------------------------------------------------------------
37
38inline
39void G4Parabola::Init(const G4Axis2Placement3D& position0,
40 G4double focalDist0)
41{
42 position= position0;
43 focalDist= focalDist0;
44
45 // focus
46 F= position.GetLocation()+focalDist*position.GetPX();
47 // line
48 L0= position.GetLocation()-focalDist*position.GetPX();
49 //l= position.GetPY();
50}
51
52inline
53G4double G4Parabola::GetFocalDist() const
54{
55 return focalDist;
56}
57
58//////////////////////////////////////////////////////////////////////////////
59
60inline
61G4double G4Parabola::GetPMax() const
62{
63 return -1;
64}
65
66inline
67G4Point3D G4Parabola::GetPoint(G4double param) const
68{
69 return G4Point3D( position.GetLocation()
70 + focalDist* (param*param*position.GetPX()
71 + 2*param*position.GetPY()) );
72}
73
74inline
75G4double G4Parabola::GetPPoint(const G4Point3D& pt) const
76{
77 G4Point3D ptLocal= position.GetToPlacementCoordinates()*pt;
78 return ptLocal.y()/(2*focalDist);
79}
80
81//////////////////////////////////////////////////////////////////////////////
82
83/*
84#include "G4CurveRayIntersection.hh"
85
86inline
87void G4Parabola::IntersectRay2D(const G4Ray& ray,
88 G4CurveRayIntersection& is)
89{
90 is.Init(*this, ray);
91
92 const G4Point3D& S= ray.GetStart();
93 const G4Vector3D& d= ray.GetDir();
94
95 const G4Vector3D& l= position.GetPY();
96
97 // a == 1
98 G4Vector3D SMinusF= S-F;
99 G4double bHalf= SMinusF*d - (d.x()*l.y()-d.y()*l.x());
100 G4double c= SMinusF.mag2() + ( (S.x()-L0.x())*l.y() - (S.y()-L0.y())*l.x() );
101
102 G4double discr= bHalf*bHalf-c;
103 if (discr >= 0) {
104
105 // 2 intersections (maybe 1, but this case is rare)
106 G4double sqrtdiscr= std::sqrt(discr);
107 // find the smallest positive i
108 G4double i= -bHalf-sqrtdiscr;
109 if (i<kCarTolerance) {
110 i= -bHalf+sqrtdiscr;
111 if (i<kCarTolerance) {
112 return;
113 }
114 }
115 G4CurveRayIntersection isTmp(*this, ray);
116 isTmp.ResetDistance(i);
117 is.Update(isTmp);
118
119 }
120}
121*/
122
123inline
124G4int G4Parabola::IntersectRay2D(const G4Ray& ray)
125{
126 // NOT VERIFIED
127
128 const G4Point3D& S= ray.GetStart();
129 const G4Vector3D& d= ray.GetDir();
130 const G4Vector3D& l= position.GetPY();
131
132 // a == 1
133 G4Vector3D SMinusF= G4Vector3D( S-F );
134 G4double bHalf= SMinusF*d - (d.x()*l.y()-d.y()*l.x());
135 G4double c= SMinusF.mag2() + ( (S.x()-L0.x())*l.y() - (S.y()-L0.y())*l.x() );
136
137 G4int nbinter = 0;
138
139 G4double discr= bHalf*bHalf-c;
140 if (discr >= 0)
141 {
142 // 2 intersections (maybe 1, but this case is rare)
143 G4double sqrtdiscr= std::sqrt(discr);
144
145 G4double i= -bHalf-sqrtdiscr;
146 if (i>kCarTolerance)
147 nbinter++;
148
149 i= -bHalf+sqrtdiscr;
150 if (i>kCarTolerance)
151 nbinter++;
152 }
153
154 return nbinter++;
155}
Note: See TracBrowser for help on using the repository browser.