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: G4SphericalSurface.hh,v 1.10 2006/06/29 18:40:36 gunter Exp $ |
---|
28 | // GEANT4 tag $Name: geant4-09-03 $ |
---|
29 | // |
---|
30 | // ---------------------------------------------------------------------- |
---|
31 | // Class G4SphericalSurface |
---|
32 | // |
---|
33 | // Class description: |
---|
34 | // |
---|
35 | // Definition of a spherical surface. |
---|
36 | |
---|
37 | // The code for G4SphericalSurface has been derived from the original |
---|
38 | // implementation in the "Gismo" package. |
---|
39 | // |
---|
40 | // Authors: L.Lim, A.Breakstone. |
---|
41 | // Adaptation: J.Sulkimo, P.Urban. |
---|
42 | // Revisions by: L.Broglia, G.Cosmo. |
---|
43 | // ---------------------------------------------------------------------- |
---|
44 | #ifndef __G4SpheShell_H |
---|
45 | #define __G4SpheShell_H |
---|
46 | |
---|
47 | #include "G4Surface.hh" |
---|
48 | #include "G4ThreeMat.hh" |
---|
49 | |
---|
50 | class G4SphericalSurface : public G4Surface |
---|
51 | { |
---|
52 | |
---|
53 | public: // with description |
---|
54 | |
---|
55 | G4SphericalSurface(); |
---|
56 | // Default constructor. |
---|
57 | |
---|
58 | G4SphericalSurface( const G4Vector3D& o, |
---|
59 | const G4Vector3D& xhat, const G4Vector3D& zhat, |
---|
60 | G4double r, |
---|
61 | G4double ph1, G4double ph2, |
---|
62 | G4double th1, G4double th2 ); |
---|
63 | // Normal constructor: |
---|
64 | // first argument is the origin of the G4SphericalSurface |
---|
65 | // second argument is the axis of the G4SphericalSurface |
---|
66 | // which defines azimuthal angle equals zero |
---|
67 | // third argument is the axis of the G4SphericalSurface |
---|
68 | // which defines polar angle equals zero |
---|
69 | // fourth argument is the radius of the G4SphericalSurface |
---|
70 | // fifth argument is the lower azimuthal angle limit of the surface |
---|
71 | // sixth argument is the upper azimuthal angle limit of the surface |
---|
72 | // seventh argument is the lower polar angle limit of the surface |
---|
73 | // eigth argument is the upper polar angle limit of the surface |
---|
74 | |
---|
75 | virtual ~G4SphericalSurface(); |
---|
76 | // Destructor. |
---|
77 | |
---|
78 | inline G4int operator==( const G4SphericalSurface& s ); |
---|
79 | // Equality operator. |
---|
80 | |
---|
81 | inline G4String GetEntityType() const; |
---|
82 | // Returns the type identifier. |
---|
83 | |
---|
84 | virtual const char* NameOf() const; |
---|
85 | // Returns the class name. |
---|
86 | |
---|
87 | virtual void PrintOn( std::ostream& os = G4cout ) const; |
---|
88 | // Printing function, streaming surface's attributes. |
---|
89 | |
---|
90 | G4int Intersect(const G4Ray&); |
---|
91 | // Returns the distance along a Ray (straight line with G4Vector3D) to |
---|
92 | // leave or enter a G4SphericalSurface. |
---|
93 | // If the G4Vector3D of the Ray is opposite to that of the Normal to |
---|
94 | // the G4SphericalSurface at the intersection point, it will not leave the |
---|
95 | // G4SphericalSurface. |
---|
96 | // Similarly, if the G4Vector3D of the Ray is along that of the Normal |
---|
97 | // to the G4SphericalSurface at the intersection point, it will not enter |
---|
98 | // the G4SphericalSurface. |
---|
99 | // This method is called by all finite shapes sub-classed to |
---|
100 | // G4SphericalSurface. |
---|
101 | // A negative result means no intersection. |
---|
102 | // If no valid intersection point is found, set the distance |
---|
103 | // and intersection point to large numbers. |
---|
104 | |
---|
105 | void CalcBBox(); |
---|
106 | // Computes the bounding-box. |
---|
107 | |
---|
108 | inline void Comp(G4Vector3D& v, G4Point3D& min , G4Point3D& max); |
---|
109 | // Compares the x,y and z values of v and min |
---|
110 | // versus v and max. min/max-values are replaced if |
---|
111 | // greater/smaller than v-values. |
---|
112 | |
---|
113 | virtual G4double HowNear( const G4Vector3D& x ) const; |
---|
114 | // Returns the distance from a point to a G4SphericalSurface |
---|
115 | // The point x is the (input) argument. |
---|
116 | // The distance is positive if the point is Inside, negative if it |
---|
117 | // is outside |
---|
118 | |
---|
119 | virtual G4Vector3D SurfaceNormal( const G4Point3D& p ) const; |
---|
120 | // Returns the Normal unit vector to the G4SphericalSurface at a point p |
---|
121 | // on (or nearly on) the G4SphericalSurface. |
---|
122 | |
---|
123 | virtual G4int Inside( const G4Vector3D& x ) const; |
---|
124 | // Returns 1 if the point x is Inside the G4SphericalSurface, 0 otherwise. |
---|
125 | |
---|
126 | virtual G4int WithinBoundary( const G4Vector3D& x ) const; |
---|
127 | // Returns 1 if the point x is within the boundary, 0 otherwise. |
---|
128 | |
---|
129 | virtual G4double Scale() const; |
---|
130 | // Returns the radius, unless it is zero, in which case it |
---|
131 | // returns 1. Used for Scale-invariant tests of surface thickness. |
---|
132 | |
---|
133 | virtual G4double Area() const; |
---|
134 | // Calculates the area of a G4SphericalSurface. |
---|
135 | |
---|
136 | virtual void resize( G4double r, G4double ph1, G4double ph2, |
---|
137 | G4double th1, G4double th2); |
---|
138 | // Resizes the G4SphericalSurface to new radius and angle limits. |
---|
139 | // first argument is the radius of the G4SphericalSurface |
---|
140 | // second argument is the lower azimuthal angle limit of the surface |
---|
141 | // third argument is the upper azimuthal angle limit of the surface |
---|
142 | // fourth argument is the lower polar angle limit of the surface |
---|
143 | // fifth argument is the upper polar angle limit of the surface |
---|
144 | |
---|
145 | inline G4Vector3D GetXAxis() const; |
---|
146 | inline G4Vector3D GetZAxis() const; |
---|
147 | inline G4double GetRadius() const; |
---|
148 | inline G4double GetPhi1() const; |
---|
149 | inline G4double GetPhi2() const; |
---|
150 | inline G4double GetTheta1() const; |
---|
151 | inline G4double GetTheta2() const; |
---|
152 | // Accessors methodss to return the axes, radius, and angles |
---|
153 | // of the G4SphericalSurface. |
---|
154 | |
---|
155 | public: // without description |
---|
156 | |
---|
157 | virtual G4Vector3D Normal( const G4Vector3D& p ) const; |
---|
158 | // Returns the Normal unit vector as for SurfaceNormal(). |
---|
159 | |
---|
160 | /* |
---|
161 | virtual G4double distanceAlongRay( G4int which_way, const G4Ray* ry, |
---|
162 | G4ThreeVec& p ) const; |
---|
163 | // Returns the distance along a Ray to enter or leave a G4SphericalSurface. |
---|
164 | // The first (input) argument is +1 to leave or -1 to enter |
---|
165 | // The second (input) argument is a pointer to the Ray |
---|
166 | // The third (output) argument returns the intersection point. |
---|
167 | |
---|
168 | virtual G4double distanceAlongHelix( G4int which_way, const Helix* hx, |
---|
169 | G4ThreeVec& p ) const; |
---|
170 | // Returns the distance along a Helix to enter or leave a G4SphericalSurface. |
---|
171 | // The first (input) argument is +1 to leave or -1 to enter |
---|
172 | // The second (input) argument is a pointer to the Helix |
---|
173 | // The third (output) argument returns the intersection point. |
---|
174 | |
---|
175 | virtual G4Vector3D Normal( const G4Point3D& p ) const; |
---|
176 | // Returns the Normal unit vector to a G4SphericalSurface at a point p |
---|
177 | // on (or nearly on) the G4SphericalSurface. |
---|
178 | |
---|
179 | virtual void rotate( G4double alpha, G4double beta, |
---|
180 | G4double gamma, G4ThreeMat& m, G4int inverse ); |
---|
181 | // Rotates the G4SphericalSurface (angles are assumed to be given in |
---|
182 | // radians), arguments: |
---|
183 | // - first about global x_axis by angle alpha, |
---|
184 | // - second about global y-axis by angle beta, |
---|
185 | // - third about global z_axis by angle gamma, |
---|
186 | // - fourth (output) argument gives the calculated rotation matrix, |
---|
187 | // - fifth (input) argument is an integer flag which if |
---|
188 | // non-zero reverses the order of the rotations. |
---|
189 | |
---|
190 | virtual void rotate( G4double alpha, G4double beta, |
---|
191 | G4double gamma, G4int inverse ); |
---|
192 | // Rotates the G4SphericalSurface (angles are assumed to be given in |
---|
193 | // radians), arguments: |
---|
194 | // - first about global x_axis by angle alpha, |
---|
195 | // - second about global y-axis by angle beta, |
---|
196 | // - third about global z_axis by angle gamma, |
---|
197 | // - fourth (input) argument is an integer flag which if |
---|
198 | // non-zero reverses the order of the rotations. |
---|
199 | */ |
---|
200 | |
---|
201 | protected: // with description |
---|
202 | |
---|
203 | G4Vector3D x_axis; |
---|
204 | // Direction (unit vector) of axis of G4SphericalSurface |
---|
205 | // which defines azimuthal angle of zero. |
---|
206 | |
---|
207 | G4Vector3D z_axis; |
---|
208 | // Direction (unit vector) of axis of G4SphericalSurface |
---|
209 | // which defines polar angle of zero. |
---|
210 | |
---|
211 | G4double radius; |
---|
212 | // Radius of G4SphericalSurface. |
---|
213 | |
---|
214 | G4double phi_1; |
---|
215 | // Lower azimuthal angle limit of G4SphericalSurface |
---|
216 | // (in radians). Allowed range: 0 <= phi_1 < 2*PI. |
---|
217 | |
---|
218 | G4double phi_2; |
---|
219 | // Upper azimuthal angle limit of G4SphericalSurface |
---|
220 | // (in radians). Allowed range: phi_1 < phi_2 <= phi_1 + 2*PI |
---|
221 | |
---|
222 | G4double theta_1; |
---|
223 | // Lower polar angle limit of G4SphericalSurface |
---|
224 | // (in radians). Allowed range: 0 <= theta_1 < PI. |
---|
225 | |
---|
226 | G4double theta_2; |
---|
227 | // Upper polar angle limit of G4SphericalSurface |
---|
228 | // (in radians). Allowed range: theta_1 < theta_2 <= theta_1 + PI. |
---|
229 | |
---|
230 | private: |
---|
231 | |
---|
232 | G4SphericalSurface(const G4SphericalSurface&); |
---|
233 | G4SphericalSurface& operator=(const G4SphericalSurface&); |
---|
234 | // Private copy constructor and assignment operator. |
---|
235 | |
---|
236 | // virtual G4double gropeAlongHelix( const Helix* hx ) const; |
---|
237 | // Private function to use a crude technique to find the intersection |
---|
238 | // of a Helix with a G4SphericalSurface. It returns the turning angle |
---|
239 | // along the Helix at which the intersection occurs or -1.0 if no |
---|
240 | // intersection point is found. The argument to the call is the pointer |
---|
241 | // to the Helix. |
---|
242 | |
---|
243 | }; |
---|
244 | |
---|
245 | #include "G4SphericalSurface.icc" |
---|
246 | |
---|
247 | #endif |
---|