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: G4ConicalSurface.hh,v 1.10 2006/06/29 18:38:44 gunter Exp $ |
---|
28 | // GEANT4 tag $Name: HEAD $ |
---|
29 | // |
---|
30 | // ---------------------------------------------------------------------- |
---|
31 | // Class G4ConicalSurface |
---|
32 | // |
---|
33 | // Class Description: |
---|
34 | // |
---|
35 | // A G4ConicalSurface is a semi-infinite conical surface defined by |
---|
36 | // an axis and an opening angle, defined as the angle between the axis |
---|
37 | // and the conical surface, with the origin being the apex of the cone. |
---|
38 | |
---|
39 | // The code for G4ConicalSurface has been derived from the original |
---|
40 | // implementation in the "Gismo" package. |
---|
41 | // |
---|
42 | // Author: A.Breakstone |
---|
43 | // Adaptation: J.Sulkimo, P.Urban. |
---|
44 | // Revisions by: L.Broglia, G.Cosmo. |
---|
45 | // ---------------------------------------------------------------------- |
---|
46 | #ifndef __G4CONICALSURFACE_H |
---|
47 | #define __G4CONICALSURFACE_H |
---|
48 | |
---|
49 | #include "G4Surface.hh" |
---|
50 | |
---|
51 | |
---|
52 | class G4ConicalSurface : public G4Surface |
---|
53 | { |
---|
54 | |
---|
55 | public: // with description |
---|
56 | |
---|
57 | G4ConicalSurface(); |
---|
58 | // Default constructor: |
---|
59 | // default axis is ( 1.0, 0.0, 0.0 ), |
---|
60 | // default angle is 1.0 radians. |
---|
61 | |
---|
62 | G4ConicalSurface( const G4Point3D& o, const G4Vector3D& a, G4double e ); |
---|
63 | // Normal constructor: |
---|
64 | // first argument is the origin of the G4ConicalSurface |
---|
65 | // second argument is the axis of the G4ConicalSurface |
---|
66 | // third argument is the angle of the G4ConicalSurface. |
---|
67 | |
---|
68 | virtual ~G4ConicalSurface(); |
---|
69 | // Virtual destructor. |
---|
70 | |
---|
71 | inline G4int operator==( const G4ConicalSurface& c ); |
---|
72 | // Equality operator. |
---|
73 | |
---|
74 | inline G4String GetEntityType() const; |
---|
75 | // Returns type identifier of the shape. |
---|
76 | |
---|
77 | virtual const char* NameOf() const; |
---|
78 | // Returns the class name. |
---|
79 | |
---|
80 | virtual void PrintOn( std::ostream& os = G4cout ) const; |
---|
81 | // Printing function, streaming surface's attributes. |
---|
82 | |
---|
83 | virtual G4double HowNear( const G4Vector3D& x ) const; |
---|
84 | // Returns the distance from a point to a semi-infinite G4ConicalSurface. |
---|
85 | // The point x is the (input) argument. |
---|
86 | // The distance is positive if the point is Inside, negative if it |
---|
87 | // is outside |
---|
88 | |
---|
89 | void CalcBBox(); |
---|
90 | // Computes the bounding-box. |
---|
91 | |
---|
92 | G4int Intersect( const G4Ray& ry ); |
---|
93 | // Returns the distance along a Ray (straight line with G4Vector3D) to |
---|
94 | // leave or enter a G4ConicalSurface. |
---|
95 | // If the G4Vector3D of the Ray is opposite to that of the Normal to |
---|
96 | // the G4ConicalSurface at the intersection point, it will not leave the |
---|
97 | // G4ConicalSurface. |
---|
98 | // Similarly, if the G4Vector3D of the Ray is along that of the Normal |
---|
99 | // to the G4ConicalSurface at the intersection point, it will not enter the |
---|
100 | // G4ConicalSurface. |
---|
101 | // This method is called by all finite shapes sub-classed to |
---|
102 | // G4ConicalSurface. |
---|
103 | // A negative result means no intersection. |
---|
104 | // If no valid intersection point is found, set the distance |
---|
105 | // and intersection point to large numbers. |
---|
106 | |
---|
107 | virtual G4Vector3D SurfaceNormal( const G4Point3D& p ) const; |
---|
108 | // Returns the Normal unit vector to the G4ConicalSurface at a point p |
---|
109 | // on (or nearly on) the G4ConicalSurface. |
---|
110 | |
---|
111 | virtual G4int Inside( const G4Vector3D& x ) const; |
---|
112 | // Returns 1 if the point x is Inside the G4ConicalSurface, 0 otherwise. |
---|
113 | // Outside means that the distance to the G4ConicalSurface would be |
---|
114 | // negative. Uses the HowNear() function to calculate this distance. |
---|
115 | |
---|
116 | virtual G4int WithinBoundary( const G4Vector3D& x ) const; |
---|
117 | // Returns 1 if point x is on the G4ConicalSurface, otherwise return zero |
---|
118 | // Since a G4ConicalSurface is infinite in extent, the function |
---|
119 | // will just check if the point is on the G4ConicalSurface (to the surface |
---|
120 | // precision). |
---|
121 | |
---|
122 | virtual G4double Scale() const; |
---|
123 | // Function overwritten by finite-sized derived classes which returns |
---|
124 | // a radius, unless it is zero, in which case it returns the smallest |
---|
125 | // non-zero dimension. |
---|
126 | // Since a semi-infinite cone has no Scale associated with it, it returns |
---|
127 | // the arbitrary number 1.0. |
---|
128 | // Used for Scale-invariant tests of surface thickness. |
---|
129 | |
---|
130 | inline G4Vector3D GetAxis() const; |
---|
131 | inline G4double GetAngle() const; |
---|
132 | // Return the axis and angle of the G4ConicalSurface. |
---|
133 | |
---|
134 | void SetAngle( G4double e ); |
---|
135 | // Changes the angle of the G4ConicalSurface. |
---|
136 | // Requires angle to range from 0 to PI/2. |
---|
137 | |
---|
138 | public: // without description |
---|
139 | |
---|
140 | /* |
---|
141 | virtual G4double distanceAlongRay( G4int which_way, const G4Ray* ry, |
---|
142 | G4Vector3D& p ) const; |
---|
143 | // Returns the distance along a Ray to enter or leave a G4ConicalSurface. |
---|
144 | // The first (input) argument is +1 to leave or -1 to enter |
---|
145 | // The second (input) argument is a pointer to the Ray |
---|
146 | // The third (output) argument returns the intersection point. |
---|
147 | |
---|
148 | virtual G4double distanceAlongHelix( G4int which_way, const Helix* hx, |
---|
149 | G4Vector3D& p ) const; |
---|
150 | // Returns the distance along a Helix to enter or leave a G4ConicalSurface. |
---|
151 | // The first (input) argument is +1 to leave or -1 to enter |
---|
152 | // The second (input) argument is a pointer to the Helix |
---|
153 | // The third (output) argument returns the intersection point. |
---|
154 | |
---|
155 | G4Vector3D Normal( const G4Vector3D& p ) const; |
---|
156 | // Returns the Normal unit vector to a G4ConicalSurface |
---|
157 | // at a point p on (or nearly on) the G4ConicalSurface. |
---|
158 | |
---|
159 | virtual void rotate( G4double alpha, G4double beta, |
---|
160 | G4double gamma, G4ThreeMat& m, G4int inverse ); |
---|
161 | // Rotates the G4ConicalSurface (angles are assumed to be given in |
---|
162 | // radians), arguments: |
---|
163 | // - first about global x-axis by angle alpha, |
---|
164 | // - second about global y-axis by angle beta, |
---|
165 | // - third about global z-axis by angle gamma, |
---|
166 | // - fourth (output) argument gives the calculated rotation matrix, |
---|
167 | // - fifth (input) argument is an integer flag which if |
---|
168 | // non-zero reverses the order of the rotations. |
---|
169 | |
---|
170 | virtual void rotate( G4double alpha, G4double beta, |
---|
171 | G4double gamma, G4int inverse ); |
---|
172 | // Rotates the G4ConicalSurface (angles are assumed to be given in |
---|
173 | // radians), arguments: |
---|
174 | // - first about global x-axis by angle alpha, |
---|
175 | // - second about global y-axis by angle beta, |
---|
176 | // - third about global z-axis by angle gamma, |
---|
177 | // - fourth (input) argument is an integer flag which if |
---|
178 | // non-zero reverses the order of the rotations. |
---|
179 | |
---|
180 | private: |
---|
181 | |
---|
182 | virtual G4double gropeAlongHelix( const Helix* hx ) const; |
---|
183 | // Private function to use a crude technique to find the intersection |
---|
184 | // of a Helix with a G4ConicalSurface. It returns the turning angle |
---|
185 | // along the Helix at which the intersection occurs or -1.0 if no |
---|
186 | // intersection point is found. |
---|
187 | // The argument to the call is the pointer to the Helix. |
---|
188 | */ |
---|
189 | |
---|
190 | private: |
---|
191 | |
---|
192 | G4ConicalSurface(const G4ConicalSurface&); |
---|
193 | G4ConicalSurface& operator=(const G4ConicalSurface&); |
---|
194 | // Private copy constructor and assignment operator. |
---|
195 | |
---|
196 | private: |
---|
197 | |
---|
198 | G4Vector3D axis; |
---|
199 | // Direction of axis of G4ConicalSurface (unit vector). |
---|
200 | |
---|
201 | G4double angle; |
---|
202 | // Half opening angle of G4ConicalSurface, in radians |
---|
203 | // range is 0 < angle < PI/2. |
---|
204 | |
---|
205 | }; |
---|
206 | |
---|
207 | #include "G4ConicalSurface.icc" |
---|
208 | |
---|
209 | #endif |
---|