Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ConicalSurface Class Reference

#include <G4ConicalSurface.hh>

+ Inheritance diagram for G4ConicalSurface:

Public Member Functions

 G4ConicalSurface ()
 
 G4ConicalSurface (const G4Point3D &o, const G4Vector3D &a, G4double e)
 
virtual ~G4ConicalSurface ()
 
G4int operator== (const G4ConicalSurface &c)
 
G4String GetEntityType () const
 
virtual const char * NameOf () const
 
virtual void PrintOn (std::ostream &os=G4cout) const
 
virtual G4double HowNear (const G4Vector3D &x) const
 
void CalcBBox ()
 
G4int Intersect (const G4Ray &ry)
 
virtual G4Vector3D SurfaceNormal (const G4Point3D &p) const
 
virtual G4int Inside (const G4Vector3D &x) const
 
virtual G4int WithinBoundary (const G4Vector3D &x) const
 
virtual G4double Scale () const
 
G4Vector3D GetAxis () const
 
G4double GetAngle () const
 
void SetAngle (G4double e)
 
- Public Member Functions inherited from G4Surface
 G4Surface ()
 
virtual ~G4Surface ()
 
G4int operator== (const G4Surface &s)
 
virtual G4String GetEntityType () const
 
virtual const char * Name () const
 
virtual G4int MyType () const
 
void SetBoundaries (G4CurveVector *)
 
virtual G4double HowNear (const G4Vector3D &x) const
 
virtual G4double ClosestDistanceToPoint (const G4Point3D &Pt)
 
G4Vector3D GetOrigin () const
 
G4double GetDistance () const
 
void SetDistance (G4double Dist)
 
G4int IsActive () const
 
void SetActive (G4int act)
 
void Deactivate ()
 
void SetSameSense (G4int sameSense0)
 
G4int GetSameSense () const
 
G4BoundingBox3DGetBBox ()
 
const G4Point3DGetClosestHit () const
 
void SetNextNode (G4Surface *)
 
G4SurfaceGetNextNode ()
 
virtual void Reset ()
 
virtual G4int Intersect (const G4Ray &)
 
virtual G4Vector3D Normal (const G4Vector3D &p) const
 
virtual void CalcBBox ()
 
virtual G4double GetUHit () const
 
virtual G4double GetVHit () const
 
virtual G4Point3D Evaluation (const G4Ray &G4Rayref)
 
virtual G4int Evaluate (register const G4Ray &Rayref)
 
virtual void Project ()
 
virtual void CalcNormal ()
 
virtual G4int IsConvex () const
 
virtual G4int GetConvex () const
 
virtual G4int GetNumberOfPoints () const
 
virtual const G4Point3DGetPoint (G4int Count) const
 
virtual G4RayNorm ()
 
virtual G4Vector3D SurfaceNormal (const G4Point3D &Pt) const =0
 
- Public Member Functions inherited from G4STEPEntity
 G4STEPEntity ()
 
virtual ~G4STEPEntity ()
 
virtual G4String GetEntityType () const =0
 

Additional Inherited Members

- Static Public Member Functions inherited from G4Surface
static void Project (G4double &Coord, const G4Point3D &Pt, const G4Plane &Pl)
 
- Protected Member Functions inherited from G4Surface
virtual void InitBounded ()
 
- Protected Attributes inherited from G4Surface
G4BoundingBox3Dbbox
 
G4Point3D closest_hit
 
G4Surfacenext
 
G4SurfaceBoundary surfaceBoundary
 
G4double kCarTolerance
 
G4double kAngTolerance
 
G4int Intersected
 
G4Vector3D origin
 
G4int Type
 
G4int AdvancedFace
 
G4int active
 
G4double distance
 
G4double uhit
 
G4double vhit
 
G4int sameSense
 

Detailed Description

Definition at line 51 of file G4ConicalSurface.hh.

Constructor & Destructor Documentation

◆ G4ConicalSurface() [1/2]

G4ConicalSurface::G4ConicalSurface ( )

Definition at line 42 of file G4ConicalSurface.cc.

43 : G4Surface(), axis(G4Vector3D(1.,0.,0.)), angle(1.)
44{
45}
HepGeom::Vector3D< G4double > G4Vector3D
Definition: G4Vector3D.hh:35

◆ G4ConicalSurface() [2/2]

G4ConicalSurface::G4ConicalSurface ( const G4Point3D o,
const G4Vector3D a,
G4double  e 
)

Definition at line 47 of file G4ConicalSurface.cc.

50 : G4Surface()
51{
52 // Normal constructor
53 // require axis to be a unit vector
54
55 G4double amag = a.mag2();
56
57 if ( amag != 0.0 )
58 {
59 axis = a*(1/amag);
60 }
61 else
62 {
63 std::ostringstream message;
64 message << "Axis has zero length." << G4endl
65 << "Default axis ( 1.0, 0.0, 0.0 ) is used.";
66 G4Exception("G4ConicalSurface::G4ConicalSurface()", "GeomSolids1001",
67 JustWarning, message);
68
69 axis = G4Vector3D( 1.0, 0.0, 0.0 );
70 }
71
72 // Require angle to range from 0 to PI/2
73 //
74 if ( ( e > 0.0 ) && ( e < ( 0.5 * pi ) ) )
75 {
76 angle = e;
77 }
78 else
79 {
80 std::ostringstream message;
81 message << "Angle out of range." << G4endl
82 << "Asked for angle out of allowed range of 0 to "
83 << 0.5*pi << " (PI/2): " << e << G4endl
84 << "Default angle of 1.0 is used.";
85 G4Exception("G4ConicalSurface::G4ConicalSurface()", "GeomSolids1001",
86 JustWarning, message);
87 angle = 1.0;
88 }
89}
@ JustWarning
double G4double
Definition: G4Types.hh:64
#define G4endl
Definition: G4ios.hh:52
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
const G4double pi

◆ ~G4ConicalSurface()

G4ConicalSurface::~G4ConicalSurface ( )
virtual

Definition at line 92 of file G4ConicalSurface.cc.

93{
94}

Member Function Documentation

◆ CalcBBox()

void G4ConicalSurface::CalcBBox ( )
virtual

Reimplemented from G4Surface.

Definition at line 119 of file G4ConicalSurface.cc.

120{
123}
G4Point3D GetBoxMin() const
G4Point3D GetBoxMax() const
const G4BoundingBox3D & BBox() const
G4BoundingBox3D * bbox
Definition: G4Surface.hh:185
G4SurfaceBoundary surfaceBoundary
Definition: G4Surface.hh:189

◆ GetAngle()

G4double G4ConicalSurface::GetAngle ( ) const
inline

Referenced by Intersect().

◆ GetAxis()

G4Vector3D G4ConicalSurface::GetAxis ( ) const
inline

Referenced by Intersect().

◆ GetEntityType()

G4String G4ConicalSurface::GetEntityType ( ) const
inlinevirtual

Reimplemented from G4Surface.

◆ HowNear()

G4double G4ConicalSurface::HowNear ( const G4Vector3D x) const
virtual

Reimplemented from G4Surface.

Definition at line 134 of file G4ConicalSurface.cc.

135{
136 // Distance from the point x to the semi-infinite G4ConicalSurface.
137 // The distance will be positive if the point is Inside the G4ConicalSurface,
138 // negative if the point is outside.
139 // Note that this may not be correct for a bounded conical object
140 // subclassed to G4ConicalSurface.
141
142 G4Vector3D d = G4Vector3D( x - origin );
143 G4double l = d * axis;
144 G4Vector3D q = G4Vector3D( origin + l * axis );
145 G4Vector3D v = G4Vector3D( x - q );
146
147 G4double Dist = ( l*std::tan(angle) - v.mag2() ) * std::cos(angle);
148
149 return Dist;
150}
G4Vector3D origin
Definition: G4Surface.hh:197

Referenced by Inside(), Intersect(), and WithinBoundary().

◆ Inside()

G4int G4ConicalSurface::Inside ( const G4Vector3D x) const
virtual

Definition at line 538 of file G4ConicalSurface.cc.

539{
540 // Return 0 if point x is outside G4ConicalSurface, 1 if Inside.
541 // Outside means that the distance to the G4ConicalSurface would be negative.
542 // Use the HowNear function to calculate this distance.
543
544 if ( HowNear( x ) >= -0.5*kCarTolerance )
545 { return 1; }
546 else
547 { return 0; }
548}
virtual G4double HowNear(const G4Vector3D &x) const
G4double kCarTolerance
Definition: G4Surface.hh:192

◆ Intersect()

G4int G4ConicalSurface::Intersect ( const G4Ray ry)
virtual

Reimplemented from G4Surface.

Definition at line 153 of file G4ConicalSurface.cc.

154{
155 // Distance along a Ray (straight line with G4Vector3D) to leave or enter
156 // a G4ConicalSurface. The input variable which_way should be set to +1 to
157 // indicate leaving a G4ConicalSurface, -1 to indicate entering a
158 // G4ConicalSurface.
159 // p is the point of intersection of the Ray with the G4ConicalSurface.
160 // If the G4Vector3D of the Ray is opposite to that of the Normal to
161 // the G4ConicalSurface at the intersection point, it will not leave the
162 // G4ConicalSurface.
163 // Similarly, if the G4Vector3D of the Ray is along that of the Normal
164 // to the G4ConicalSurface at the intersection point, it will not enter the
165 // G4ConicalSurface.
166 // This method is called by all finite shapes sub-classed to
167 // G4ConicalSurface.
168 // Use the virtual function table to check if the intersection point
169 // is within the boundary of the finite shape.
170 // A negative result means no intersection.
171 // If no valid intersection point is found, set the distance
172 // and intersection point to large numbers.
173
174 G4int which_way = -1; // Originally a parameter.Read explanation above.
175
176 distance = kInfinity;
177
178 G4Vector3D lv ( kInfinity, kInfinity, kInfinity );
179 closest_hit = lv;
180
181 // Origin and G4Vector3D unit vector of Ray.
182 //
183 G4Vector3D x = G4Vector3D( ry.GetStart() );
184 G4Vector3D dhat = ry.GetDir();
185
186
187 // Cone angle and axis unit vector.
188 //
189 G4double ta = std::tan( GetAngle() );
190 G4Vector3D ahat = GetAxis();
191 G4int isoln = 0,
192 maxsoln = 2;
193
194 // array of solutions in distance along the Ray
195 //
196 G4double sol[2];
197 sol[0] = -1.0;
198 sol[1] = -1.0 ;
199
200 // calculate the two solutions (quadratic equation)
201 //
202 G4Vector3D gamma = G4Vector3D( x - GetOrigin() );
203 G4double T = 1.0 + ta * ta;
204 G4double ga = gamma * ahat;
205 G4double da = dhat * ahat;
206 G4double A = 1.0 - T * da * da;
207 G4double B = 2.0 * ( gamma * dhat - T * ga * da );
208 G4double C = gamma * gamma - T * ga * ga;
209
210 // if quadratic term vanishes, just do the simple solution
211 //
212 if ( std::fabs( A ) < kCarTolerance )
213 {
214 if ( B == 0.0 )
215 { return 1; }
216 else
217 { sol[0] = -C / B; }
218 }
219
220 // Normal quadratic case, no intersection if radical is less than zero
221 //
222 else
223 {
224 G4double radical = B * B - 4.0 * A * C;
225 if ( radical < 0.0 )
226 {
227 return 1;
228 }
229 else
230 {
231 G4double root = std::sqrt( radical );
232 sol[0] = ( - B + root ) / ( 2. * A );
233 sol[1] = ( - B - root ) / ( 2. * A );
234 }
235 }
236
237 // order the possible solutions by increasing distance along the Ray
238 //
239 sort_double( sol, isoln, maxsoln-1 );
240
241 // now loop over each positive solution, keeping the first one (smallest
242 // distance along the Ray) which is within the boundary of the sub-shape
243 // and which also has the correct G4Vector3D with respect to the Normal to
244 // the G4ConicalSurface at the intersection point
245 //
246 for ( isoln = 0; isoln < maxsoln; isoln++ )
247 {
248 if ( sol[isoln] >= 0.0 )
249 {
250 if ( sol[isoln] >= kInfinity ) // quit if too large
251 {
252 return 1;
253 }
254
255 distance = sol[isoln];
257
258 // Following line necessary to select non-reflective solutions.
259 //
260 if (( ahat * ( closest_hit - GetOrigin() ) > 0.0 ) &&
261 ((( dhat * SurfaceNormal( closest_hit ) * which_way )) >= 0.0 ) &&
262 ( std::fabs(HowNear( closest_hit )) < 0.1) )
263 {
264 return 1;
265 }
266 }
267 }
268
269 // get here only if there was no solution within the boundary, Reset
270 // distance and intersection point to large numbers
271 //
272 distance = kInfinity;
273 closest_hit = lv;
274
275 return 0;
276}
void sort_double(G4double[], G4int, G4int)
Definition: G4Sort.cc:39
int G4int
Definition: G4Types.hh:66
virtual G4Vector3D SurfaceNormal(const G4Point3D &p) const
G4Vector3D GetAxis() const
G4double GetAngle() const
G4Point3D GetPoint(G4double i) const
const G4Vector3D & GetDir() const
const G4Point3D & GetStart() const
G4double distance
Definition: G4Surface.hh:203
G4Vector3D GetOrigin() const
G4Point3D closest_hit
Definition: G4Surface.hh:186

◆ NameOf()

const char * G4ConicalSurface::NameOf ( ) const
virtual

Definition at line 114 of file G4ConicalSurface.cc.

115{
116 return "G4ConicalSurface";
117}

◆ operator==()

G4int G4ConicalSurface::operator== ( const G4ConicalSurface c)
inline

◆ PrintOn()

void G4ConicalSurface::PrintOn ( std::ostream &  os = G4cout) const
virtual

Definition at line 125 of file G4ConicalSurface.cc.

126{
127 // printing function using C++ std::ostream class
128
129 os << "G4ConicalSurface surface with origin: " << origin << "\t"
130 << "angle: " << angle << " radians \tand axis " << axis << "\n";
131}

◆ Scale()

G4double G4ConicalSurface::Scale ( ) const
virtual

Definition at line 562 of file G4ConicalSurface.cc.

563{
564 return 1.0;
565}

Referenced by WithinBoundary().

◆ SetAngle()

void G4ConicalSurface::SetAngle ( G4double  e)

Definition at line 567 of file G4ConicalSurface.cc.

568{
569 // Reset the angle of the G4ConicalSurface
570 // Require angle to range from 0 to PI/2
571
572 if ( (e > 0.0) && (e <= ( 0.5 * pi )) )
573 {
574 angle = e;
575 }
576 else // use old value (do not change angle) if out of the range,
577 { // but print warning message
578 std::ostringstream message;
579 message << "Angle out of range." << G4endl
580 << "Asked for angle out of allowed range of 0 to "
581 << 0.5*pi << " (PI/2): " << e << G4endl
582 << "Default angle of " << angle << " is used.";
583 G4Exception("G4ConicalSurface::SetAngle()", "GeomSolids1001",
584 JustWarning, message);
585 }
586}

◆ SurfaceNormal()

G4Vector3D G4ConicalSurface::SurfaceNormal ( const G4Point3D p) const
virtual

Implements G4Surface.

Definition at line 497 of file G4ConicalSurface.cc.

498{
499 // return the Normal unit vector to the G4ConicalSurface at a point p
500 // on (or nearly on) the G4ConicalSurface
501
502 G4Vector3D ss = G4Vector3D( p - origin );
503 G4double smag = ss.mag2();
504
505 // if the point happens to be at the origin, calculate a unit vector Normal
506 // to the axis, with zero z component
507 //
508 if ( smag == 0.0 )
509 {
510 G4double ax = axis.x();
511 G4double ay = axis.y();
512 G4double ap = std::sqrt( ax * ax + ay * ay );
513
514 if ( ap == 0.0 )
515 { return G4Vector3D( 1.0, 0.0, 0.0 ); }
516 else
517 { return G4Vector3D( ay / ap, -ax / ap, 0.0 ); }
518 }
519 else // otherwise do the calculation of the Normal to the conical surface
520 {
521 G4double l = ss * axis;
522 ss = ss*(1/smag);
523 G4Vector3D q = G4Vector3D( origin + l * axis );
524 G4Vector3D v = G4Vector3D( p - q );
525 G4double sl = v.mag2() * std::sin( angle );
526 G4Vector3D n = G4Vector3D( v - sl * ss );
527 G4double nmag = n.mag2();
528
529 if ( nmag != 0.0 )
530 {
531 n=n*(1/nmag);
532 }
533 return n;
534 }
535}

Referenced by Intersect().

◆ WithinBoundary()

G4int G4ConicalSurface::WithinBoundary ( const G4Vector3D x) const
virtual

Definition at line 551 of file G4ConicalSurface.cc.

552{
553 // return 1 if point x is on the G4ConicalSurface, otherwise return zero
554 // base this on the surface precision factor
555
556 if ( std::fabs( HowNear( x ) / Scale() ) <= SURFACE_PRECISION )
557 { return 1; }
558 else
559 { return 0; }
560}
#define SURFACE_PRECISION
Definition: G4Globals.hh:47
virtual G4double Scale() const

The documentation for this class was generated from the following files: