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

#include <G4Ray.hh>

Public Member Functions

 G4Ray ()
 
 G4Ray (const G4Point3D &start0, const G4Vector3D &dir0)
 
 ~G4Ray ()
 
G4Point3D GetPoint (G4double i) const
 
G4double GetPPoint (const G4Point3D &p) const
 
const G4Vector3DGetDir () const
 
const G4Point3DGetStart () const
 
void SetDir (const G4Vector3D &dir0)
 
void SetStart (const G4Point3D &start0)
 
const G4PlaneGetPlane (G4int number_of_plane) const
 
void RayCheck ()
 
void CreatePlanes ()
 
G4double P2 (G4double x) const
 
G4int NearZero (G4double val, G4double epsilon) const
 
void MatVecOrtho (register G4Vector3D &out, register const G4Vector3D &in)
 
void Vsetall (G4Vector3D &a, G4double s)
 
void Init (const G4Point3D &start0, const G4Vector3D &dir0)
 

Static Public Member Functions

static G4int CalcPlane3Pts (G4Plane &plane, const G4Point3D &a, const G4Point3D &b, const G4Point3D &c)
 
static void Vcross (G4Plane &a, const G4Vector3D &b, const G4Vector3D &c)
 
static void Vcross (G4Vector3D &a, const G4Vector3D &b, const G4Vector3D &c)
 
static void Vmove (G4Point3D &a, const G4Point3D &b)
 
static void Vadd2 (G4Point3D &a, const G4Point3D &b, const G4Vector3D &c)
 
static void Vsub2 (G4Vector3D &a, const G4Point3D &b, const G4Point3D &c)
 
static void Vscale (G4Plane &a, const G4Plane &b, G4double c)
 
static G4double Vdot (const G4Plane &a, const G4Point3D &b)
 
static G4double Magsq (const G4Plane &a)
 
static G4double Magnitude (const G4Plane &a)
 

Detailed Description

Definition at line 48 of file G4Ray.hh.

Constructor & Destructor Documentation

◆ G4Ray() [1/2]

G4Ray::G4Ray ( )

Definition at line 39 of file G4Ray.cc.

40 : r_min(0.), r_max(0.)
41{
42}

◆ G4Ray() [2/2]

G4Ray::G4Ray ( const G4Point3D start0,
const G4Vector3D dir0 
)

Definition at line 44 of file G4Ray.cc.

45{
46 Init(start0, dir0);
47}
void Init(const G4Point3D &start0, const G4Vector3D &dir0)

◆ ~G4Ray()

G4Ray::~G4Ray ( )

Definition at line 49 of file G4Ray.cc.

50{
51}

Member Function Documentation

◆ CalcPlane3Pts()

G4int G4Ray::CalcPlane3Pts ( G4Plane plane,
const G4Point3D a,
const G4Point3D b,
const G4Point3D c 
)
static

Definition at line 212 of file G4Ray.cc.

216{
217 // Creates the two orthogonal planes which are needed in projecting the
218 // surface into 2D.
219
220 G4Vector3D B_A;
221 G4Vector3D C_A;
222 G4Vector3D C_B;
223
224 register G4double mag;
225
226 Vsub2( B_A, b, a );
227 Vsub2( C_A, c, a );
228 Vsub2( C_B, c, b );
229
230 Vcross( plane1, B_A, C_A );
231
232 // Ensure unit length Normal
233 mag = Magnitude(plane1);
234 if( mag <= SQRT_SMALL_FASTF )
235 {
236 return(-1);// FAIL
237 }
238
239 mag = 1/mag;
240
241 G4Plane pl2(plane1);
242 Vscale( plane1, pl2, mag );
243
244 // Find distance from the origin to the G4Plane
245 plane1.d = Vdot( plane1, a );
246
247 return(0); //ok
248}
#define SQRT_SMALL_FASTF
Definition: G4PointRat.hh:49
double G4double
Definition: G4Types.hh:64
G4double d
Definition: G4Plane.hh:52
static G4double Vdot(const G4Plane &a, const G4Point3D &b)
Definition: G4Ray.cc:315
static void Vcross(G4Plane &a, const G4Vector3D &b, const G4Vector3D &c)
Definition: G4Ray.cc:267
static void Vscale(G4Plane &a, const G4Plane &b, G4double c)
Definition: G4Ray.cc:307
static void Vsub2(G4Vector3D &a, const G4Point3D &b, const G4Point3D &c)
Definition: G4Ray.cc:299
static G4double Magnitude(const G4Plane &a)
Definition: G4Ray.cc:329

Referenced by CreatePlanes(), and G4FPlane::G4FPlane().

◆ CreatePlanes()

void G4Ray::CreatePlanes ( )

Definition at line 63 of file G4Ray.cc.

64{
65 // Creates two orthogonal planes(plane1,plane2) the ray (rray)
66 // situated in the intersection of the planes. The planes are
67 // used to project the surface (nurb) in two dimensions.
68
69 G4Vector3D RayDir = dir;
70 G4Point3D RayOrigin = start;
71
72 G4Point3D p1, p2, p3, p4;
73 G4Vector3D dir1, dir2;
75
76 if(!NearZero(RayDir.x(), SQRT_SMALL_FASTF))
77 { invdir.setX(1.0 / RayDir.x()); }
78
79 if(!NearZero(RayDir.y(), SQRT_SMALL_FASTF))
80 { invdir.setY(1.0 / RayDir.y()); }
81
82 if(!NearZero(RayDir.z(), SQRT_SMALL_FASTF))
83 { invdir.setZ(1.0 / RayDir.z()); }
84
85 MatVecOrtho(dir1, RayDir);
86
87 Vcross( dir2, RayDir, dir1);
88 Vmove(p1, RayOrigin);
89 Vadd2(p2, RayOrigin, RayDir);
90 Vadd2(p3, RayOrigin, dir1);
91 Vadd2(p4, RayOrigin, dir2);
92
93 CalcPlane3Pts( plane1, p1, p3, p2);
94 CalcPlane3Pts( plane2, p1, p2, p4);
95}
const G4Point3D PINFINITY(kInfinity, kInfinity, kInfinity)
HepGeom::Vector3D< G4double > G4Vector3D
Definition: G4Vector3D.hh:35
G4int NearZero(G4double val, G4double epsilon) const
static void Vmove(G4Point3D &a, const G4Point3D &b)
Definition: G4Ray.cc:283
static G4int CalcPlane3Pts(G4Plane &plane, const G4Point3D &a, const G4Point3D &b, const G4Point3D &c)
Definition: G4Ray.cc:212
void MatVecOrtho(register G4Vector3D &out, register const G4Vector3D &in)
Definition: G4Ray.cc:98
static void Vadd2(G4Point3D &a, const G4Point3D &b, const G4Vector3D &c)
Definition: G4Ray.cc:291

Referenced by G4FPlane::CalcNormal().

◆ GetDir()

◆ GetPlane()

const G4Plane & G4Ray::GetPlane ( G4int  number_of_plane) const

Definition at line 54 of file G4Ray.cc.

55{
56 if(number_of_plane==1)
57 { return plane2; }
58 else
59 { return plane1; }
60}

◆ GetPoint()

◆ GetPPoint()

G4double G4Ray::GetPPoint ( const G4Point3D p) const
inline

◆ GetStart()

◆ Init()

void G4Ray::Init ( const G4Point3D start0,
const G4Vector3D dir0 
)

Referenced by G4Ray().

◆ Magnitude()

G4double G4Ray::Magnitude ( const G4Plane a)
static

Definition at line 329 of file G4Ray.cc.

330{
331 return (std::sqrt( Magsq( a )) );
332}
static G4double Magsq(const G4Plane &a)
Definition: G4Ray.cc:323

Referenced by CalcPlane3Pts().

◆ Magsq()

G4double G4Ray::Magsq ( const G4Plane a)
static

Definition at line 323 of file G4Ray.cc.

324{
325 return ( a.a * a.a + a.b * a.b + a.c *a.c );
326}
G4double a
Definition: G4Plane.hh:52
G4double c
Definition: G4Plane.hh:52
G4double b
Definition: G4Plane.hh:52

Referenced by Magnitude().

◆ MatVecOrtho()

void G4Ray::MatVecOrtho ( register G4Vector3D out,
register const G4Vector3D in 
)

Definition at line 98 of file G4Ray.cc.

100{
101 register G4double f;
102 G4int i_Which;
103
104 if( NearZero(in.x(), 0.0001)
105 && NearZero(in.y(), 0.0001)
106 && NearZero(in.z(), 0.0001) )
107 {
108 Vsetall( out, 0 );
109 return;
110 }
111
112 // Find component closest to zero
113 f = std::fabs(in.x());
114 i_Which=0;
115
116 if( std::fabs(in.y()) < f )
117 {
118 f = std::fabs(in.y());
119 i_Which=1;
120 }
121
122 if( std::fabs(in.z()) < f )
123 {
124 i_Which=2;
125 }
126
127 if(!i_Which)
128 {
129 f = std::sqrt((in.y())*(in.y())+(in.z())*(in.z())); // hypot(in.y(),in.z())
130 }
131 else
132 {
133 if(i_Which==1)
134 {
135 f = std::sqrt((in.z())*(in.z())+(in.x())*(in.x())); // hypot(in.z(),in.x())
136 }
137 else
138 {
139 f = std::sqrt((in.x())*(in.x())+(in.y())*(in.y())); // hypot(in.x(),in.y())
140 }
141 }
142 if( NearZero( f, SMALL ) )
143 {
144 Vsetall( out, 0 );
145 return;
146 }
147
148 f = 1.0/f;
149
150 if(!i_Which)
151 {
152 out.setX(0.0);
153 out.setY(-in.z()*f);
154 out.setZ( in.y()*f);
155 }
156 else
157 {
158 if(i_Which==1)
159 {
160 out.setY(0.0);
161 out.setZ(-in.x()*f);
162 out.setX( in.y()*f);
163 }
164 else
165 {
166 out.setZ(0.0);
167 out.setX(-in.z()*f);
168 out.setY( in.y()*f);
169 }
170 }
171}
#define SMALL
Definition: G4PointRat.hh:50
int G4int
Definition: G4Types.hh:66
void Vsetall(G4Vector3D &a, G4double s)

Referenced by CreatePlanes().

◆ NearZero()

G4int G4Ray::NearZero ( G4double  val,
G4double  epsilon 
) const
inline

Referenced by CreatePlanes(), and MatVecOrtho().

◆ P2()

G4double G4Ray::P2 ( G4double  x) const
inline

◆ RayCheck()

void G4Ray::RayCheck ( )

Definition at line 251 of file G4Ray.cc.

252{
253 // Check that the ray has a G4Vector3D...
254 if (dir==G4Vector3D(0, 0, 0))
255 {
256 G4Exception("G4Ray::RayCheck()", "GeomSolids0002", FatalException,
257 "Invalid zero direction given !");
258 }
259
260 // Make sure that the vector is unit length
261 dir= dir.unit();
262 r_min = 0;
263 r_max = 0;
264}
@ FatalException
BasicVector3D< T > unit() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Referenced by G4FPlane::CalcNormal().

◆ SetDir()

void G4Ray::SetDir ( const G4Vector3D dir0)
inline

◆ SetStart()

void G4Ray::SetStart ( const G4Point3D start0)
inline

◆ Vadd2()

void G4Ray::Vadd2 ( G4Point3D a,
const G4Point3D b,
const G4Vector3D c 
)
static

Definition at line 291 of file G4Ray.cc.

292{
293 a.setX(b.x() + c.x()) ;
294 a.setY(b.y() + c.y()) ;
295 a.setZ(b.z() + c.z()) ;
296}

Referenced by CreatePlanes().

◆ Vcross() [1/2]

void G4Ray::Vcross ( G4Plane a,
const G4Vector3D b,
const G4Vector3D c 
)
static

Definition at line 267 of file G4Ray.cc.

268{
269 a.a = b.y() * c.z() - b.z() * c.y() ;
270 a.b = b.z() * c.x() - b.x() * c.z() ;
271 a.c = b.x() * c.y() - b.y() * c.x() ;
272}

Referenced by CalcPlane3Pts(), and CreatePlanes().

◆ Vcross() [2/2]

void G4Ray::Vcross ( G4Vector3D a,
const G4Vector3D b,
const G4Vector3D c 
)
static

Definition at line 275 of file G4Ray.cc.

276{
277 a.setX(b.y() * c.z() - b.z() * c.y()) ;
278 a.setY(b.z() * c.x() - b.x() * c.z()) ;
279 a.setZ(b.x() * c.y() - b.y() * c.x()) ;
280}

◆ Vdot()

G4double G4Ray::Vdot ( const G4Plane a,
const G4Point3D b 
)
static

Definition at line 315 of file G4Ray.cc.

316{
317 return (a.a * b.x() +
318 a.b * b.y() +
319 a.c * b.z());
320}

Referenced by CalcPlane3Pts().

◆ Vmove()

void G4Ray::Vmove ( G4Point3D a,
const G4Point3D b 
)
static

Definition at line 283 of file G4Ray.cc.

284{
285 a.setX(b.x());
286 a.setY(b.y());
287 a.setZ(b.z());
288}

Referenced by CreatePlanes().

◆ Vscale()

void G4Ray::Vscale ( G4Plane a,
const G4Plane b,
G4double  c 
)
static

Definition at line 307 of file G4Ray.cc.

308{
309 a.a = b.a * c;
310 a.b = b.b * c;
311 a.c = b.c * c;
312}

Referenced by CalcPlane3Pts().

◆ Vsetall()

void G4Ray::Vsetall ( G4Vector3D a,
G4double  s 
)
inline

Referenced by MatVecOrtho().

◆ Vsub2()

void G4Ray::Vsub2 ( G4Vector3D a,
const G4Point3D b,
const G4Point3D c 
)
static

Definition at line 299 of file G4Ray.cc.

300{
301 a.setX(b.x() - c.x());
302 a.setY(b.y() - c.y());
303 a.setZ(b.z() - c.z());
304}

Referenced by CalcPlane3Pts().


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