Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4Ray.hh
Go to the documentation of this file.
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$
28 //
29 // ----------------------------------------------------------------------
30 // Class G4Ray
31 //
32 // Class description:
33 //
34 // Definition of a generic ray.
35 
36 // Authors: J.Sulkimo, P.Urban.
37 // Revisions by: L.Broglia, G.Cosmo.
38 // ----------------------------------------------------------------------
39 #ifndef __G4Ray_h
40 #define __G4Ray_h 1
41 
42 #include "G4Point3D.hh"
43 #include "G4PointRat.hh"
44 #include "G4Vector3D.hh"
45 #include "G4Plane.hh"
46 
47 
48 class G4Ray
49 {
50 
51 public: // with description
52 
53  G4Ray();
54  G4Ray(const G4Point3D& start0, const G4Vector3D& dir0);
55  ~G4Ray();
56  // Contructors and destructor.
57 
58  inline G4Point3D GetPoint(G4double i) const;
59  inline G4double GetPPoint(const G4Point3D& p) const;
60  inline const G4Vector3D& GetDir() const;
61  inline const G4Point3D& GetStart() const;
62  inline void SetDir(const G4Vector3D& dir0);
63  inline void SetStart(const G4Point3D& start0);
64  const G4Plane& GetPlane(G4int number_of_plane) const;
65  // Get/Set methods of geometrical data.
66 
67  void RayCheck();
68  // Makes sure that the vector has unit length.
69 
70  void CreatePlanes();
71  // Creates two orthogonal planes (plane1,plane2), the ray (rray)
72  // being situated in the intersection of the planes. The planes are
73  // used to project the surface (nurb) in two dimensions.
74 
75  static G4int CalcPlane3Pts( G4Plane& plane, const G4Point3D& a,
76  const G4Point3D& b, const G4Point3D& c );
77  // Finds the equation of a G4Plane that contains three points.
78  // Note that Normal vector created is expected to point outside.
79  // This follows the outward-pointing Normal convention, and the
80  // right-hand rule for cross products.
81  /*
82 
83  C
84  *
85  |\
86  | \
87  ^ N | \
88  | \ | \
89  | \ | \
90  |C-A \ | \
91  | \ | \
92  | \ | \
93  \| \
94  *---------*
95  A B
96  ----->
97  B-A
98  */
99  // If the points are given in the order A B C (eg, *counter*-clockwise),
100  // then the outward pointing surface Normal N = (B-A) x (C-A).
101  //
102  // Explicit return value:
103  // 0 OK
104  // -1 Failure. At least two of the points were not distinct,
105  // or all three were colinear.
106  //
107  // Implicit return argument:
108  // plane The G4Plane equation coefficients are stored here.
109 
110  inline G4double P2(G4double x) const;
111  inline G4int NearZero(G4double val, G4double epsilon) const;
112  void MatVecOrtho(register G4Vector3D &out, register const G4Vector3D &in);
113  // Utility methods.
114 
115  inline void Vsetall(G4Vector3D &a, G4double s);
116  // Sets all elements of vector to the same scalar value.
117 
118  static void Vcross(G4Plane &a, const G4Vector3D &b,
119  const G4Vector3D &c);
120  // Cross product of 'b' and 'c'. Stores result in 'a' (G4Plane).
121 
122  static void Vcross(G4Vector3D &a, const G4Vector3D &b,
123  const G4Vector3D &c);
124  // Cross product of 'b' and 'c'. Stores result in 'a' (G4Vector3D).
125 
126  static void Vmove(G4Point3D &a, const G4Point3D &b);
127  // Sets 'a' equal to 'b'.
128 
129  static void Vadd2(G4Point3D &a, const G4Point3D &b,
130  const G4Vector3D &c );
131  // Adds vector 'c' to 'b'. Stores result in 'a'.
132 
133  static void Vsub2(G4Vector3D &a, const G4Point3D &b,
134  const G4Point3D &c);
135  // Subtracts vector 'c' from 'b'. Stores result in 'a'.
136 
137  static void Vscale(G4Plane& a, const G4Plane& b, G4double c);
138  // Scales vector at `b' by scalar `c'. Stores result in `a'.
139 
140  static G4double Vdot(const G4Plane &a, const G4Point3D &b);
141  // Computes dot product of vectors at `a' and `b'.
142 
143  static G4double Magsq(const G4Plane &a);
144  // Returns scalar Magnitude squared of vector at `a'.
145 
146  static G4double Magnitude(const G4Plane &a);
147  // Returns scalar Magnitude of vector at `a'.
148 
149 public: // without description
150 
151  void Init(const G4Point3D& start0, const G4Vector3D& dir0);
152  // Initialisation of a G4Ray (called by constructor).
153 
154 private:
155 
156  G4Point3D start;
157  G4Vector3D dir;
158 
159  G4double r_min; // entry Dist to bounding sphere
160  G4double r_max; // exit Dist from bounding sphere
161 
162  G4Plane plane1, plane2;
163 
164 };
165 
166 #include "G4Ray.icc"
167 
168 #endif