Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4GeomTools.hh
이 파일의 문서화 페이지로 가기
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 // --------------------------------------------------------------------
31 // class G4GeomTools
32 //
33 // Class description:
34 //
35 // A collection of utilities which can be helpfull for a wide range
36 // of geometry-related tasks
37 
38 // History:
39 //
40 // 10.10.2016 E.Tcherniaev: Initial version.
41 // --------------------------------------------------------------------
42 
43 #ifndef G4GEOMTOOLS_HH
44 #define G4GEOMTOOLS_HH
45 
46 #include <vector>
47 #include "G4TwoVector.hh"
48 #include "G4ThreeVector.hh"
49 
50 typedef std::vector<G4TwoVector> G4TwoVectorList;
51 typedef std::vector<G4ThreeVector> G4ThreeVectorList;
52 
54 {
55  public:
56 
57  // ==================================================================
58  // 2D Utilities
59  // ------------------------------------------------------------------
60 
61  static G4double TriangleArea(G4double Ax, G4double Ay,
62  G4double Bx, G4double By,
63  G4double Cx, G4double Cy);
64 
65  static G4double TriangleArea(const G4TwoVector& A,
66  const G4TwoVector& B,
67  const G4TwoVector& C);
68  // Calcuate area of 2D triangle, return value is positive if
69  // vertices of the triangle are given in anticlockwise order,
70  // otherwise it is negative
71 
72  static G4double QuadArea(const G4TwoVector& A,
73  const G4TwoVector& B,
74  const G4TwoVector& C,
75  const G4TwoVector& D);
76  // Calcuate area of 2D quadrilateral, return value is positive if
77  // vertices of the quadrilateral are given in anticlockwise order,
78  // otherwise it is negative
79 
80  static G4double PolygonArea(const G4TwoVectorList& polygon);
81  // Calcuate area of 2D polygon, return value is positive if
82  // vertices of the polygon are defined in anticlockwise order,
83  // otherwise it is negative
84 
86  G4double Ax, G4double Ay,
87  G4double Bx, G4double By,
88  G4double Cx, G4double Cy);
89  // Decide if point (Px,Py) is inside triangle (Ax,Ay)(Bx,By)(Cx,Cy)
90 
91  static G4bool PointInTriangle(const G4TwoVector& P,
92  const G4TwoVector& A,
93  const G4TwoVector& B,
94  const G4TwoVector& C);
95  // Decide if point P is inside triangle ABC
96 
97  static G4bool PointInPolygon(const G4TwoVector& P,
98  const G4TwoVectorList& Polygon);
99  // Decide if point P is inside Polygon
100 
101  static G4bool IsConvex(const G4TwoVectorList& polygon);
102  // Decide if 2D polygon is convex, i.e. all internal angles are
103  // less than pi
104 
105  static G4bool TriangulatePolygon(const G4TwoVectorList& polygon,
107 
108  static G4bool TriangulatePolygon(const G4TwoVectorList& polygon,
109  std::vector<G4int>& result);
110  // Simple implementation of "ear clipping" algorithm for
111  // triangulation of a simple contour/polygon, it places results
112  // in a std::vector as triplets of vertices. If triangulation
113  // is sucsessfull then the function returns true, otherwise false
114 
115  static void RemoveRedundantVertices(G4TwoVectorList& polygon,
116  std::vector<G4int>& iout,
117  G4double tolerance = 0);
118  // Remove collinear and coincident points from 2D polygon.
119  // Indices of removed points are available in iout.
120 
121  static G4bool DiskExtent(G4double rmin, G4double rmax,
122  G4double startPhi, G4double delPhi,
123  G4TwoVector& pmin, G4TwoVector& pmax);
124  // Calculate bounding rectangle of a disk sector,
125  // it returns false if input parameters do not meet the following:
126  // rmin >= 0
127  // rmax > rmin + kCarTolerance
128  // delPhi > 0 + kCarTolerance
129 
130  static void DiskExtent(G4double rmin, G4double rmax,
131  G4double sinPhiStart, G4double cosPhiStart,
132  G4double sinPhiEnd, G4double cosPhiEnd,
133  G4TwoVector& pmin, G4TwoVector& pmax);
134  // Calculate bounding rectangle of a disk sector,
135  // faster version without check of parameters
136 
138  G4double b);
139  // Compute the circumference (perimeter) of an ellipse
140 
142  G4double b,
143  G4double h);
144  // Compute the lateral surface area of an elliptic cone
145 
146  // ==================================================================
147  // 3D Utilities
148  // ------------------------------------------------------------------
149 
151  const G4ThreeVector& B,
152  const G4ThreeVector& C);
153  // Find the normal to the plane of 3D triangle ABC,
154  // length of the normal is equal to the area of the triangle
155 
157  const G4ThreeVector& B,
158  const G4ThreeVector& C,
159  const G4ThreeVector& D);
160  // Find normal to the plane of 3D quadrilateral ABCD,
161  // length of the normal is equal to the area of the quadrilateral
162 
163  static G4ThreeVector PolygonAreaNormal(const G4ThreeVectorList& polygon);
164  // Find normal to the plane of 3D polygon
165  // length of the normal is equal to the area of the polygon
166 
167  /*
168  static G4bool IsPlanar(const G4ThreeVector& A,
169  const G4ThreeVector& B,
170  const G4ThreeVector& C,
171  const G4ThreeVector& D);
172  // Decide if 3D quadrilateral ABCD is planar
173 
174  static G4bool IsPlanar(const G4ThreeVectorList& polygon
175  const G4ThreeVector& normal);
176  // Decide if 3D polygon is planar
177  */
178 
180  const G4ThreeVector& A,
181  const G4ThreeVector& B);
182  // Calculate distance between point P and line segment AB in 3D
183 
185  const G4ThreeVector& A,
186  const G4ThreeVector& B);
187  // Find point on 3D line segment AB closest to point P
188 
190  const G4ThreeVector& A,
191  const G4ThreeVector& B,
192  const G4ThreeVector& C);
193  // Find point on 3D triangle ABC closest to point P
194 
195  static G4bool SphereExtent(G4double rmin, G4double rmax,
196  G4double startTheta, G4double delTheta,
197  G4double startPhi, G4double delPhi,
198  G4ThreeVector& pmin, G4ThreeVector& pmax);
199  // Calculate bounding box of a spherical sector,
200  // it returns false if input parameters do not meet the following:
201  // rmin >= 0
202  // rmax > rmin + kCarTolerance
203  // startTheta >= 0 && <= pi;
204  // delTheta > 0 + kCarTolerance
205  // delPhi > 0 + kCarTolerance
206 
207  private:
208 
209  static G4bool CheckSnip(const G4TwoVectorList& contour,
210  G4int a, G4int b, G4int c,
211  G4int n, const G4int* V);
212  // Helper function for TriangulatePolygon()
213 
215  // Complete Elliptic Integral of the Second Kind
216 };
217 
218 #endif // G4GEOMTOOLS_HH
static G4bool TriangulatePolygon(const G4TwoVectorList &polygon, G4TwoVectorList &result)
Definition: G4GeomTools.cc:199
static G4double comp_ellint_2(G4double e)
Definition: G4GeomTools.cc:576
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
static G4ThreeVector ClosestPointOnTriangle(const G4ThreeVector &P, const G4ThreeVector &A, const G4ThreeVector &B, const G4ThreeVector &C)
Definition: G4GeomTools.cc:692
static G4double DistancePointSegment(const G4ThreeVector &P, const G4ThreeVector &A, const G4ThreeVector &B)
Definition: G4GeomTools.cc:642
double D(double temp)
static G4ThreeVector PolygonAreaNormal(const G4ThreeVectorList &polygon)
Definition: G4GeomTools.cc:626
static G4bool DiskExtent(G4double rmin, G4double rmax, G4double startPhi, G4double delPhi, G4TwoVector &pmin, G4TwoVector &pmax)
Definition: G4GeomTools.cc:396
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
std::vector< G4ThreeVector > G4ThreeVectorList
static G4ThreeVector QuadAreaNormal(const G4ThreeVector &A, const G4ThreeVector &B, const G4ThreeVector &C, const G4ThreeVector &D)
Definition: G4GeomTools.cc:614
double A(double temperature)
static G4bool IsConvex(const G4TwoVectorList &polygon)
Definition: G4GeomTools.cc:171
static G4double TriangleArea(G4double Ax, G4double Ay, G4double Bx, G4double By, G4double Cx, G4double Cy)
Definition: G4GeomTools.cc:47
static G4double EllipsePerimeter(G4double a, G4double b)
Definition: G4GeomTools.cc:538
G4double G4ParticleHPJENDLHEData::G4double result
static double P[]
static G4double EllipticConeLateralArea(G4double a, G4double b, G4double h)
Definition: G4GeomTools.cc:552
static G4bool PointInTriangle(G4double Px, G4double Py, G4double Ax, G4double Ay, G4double Bx, G4double By, G4double Cx, G4double Cy)
Definition: G4GeomTools.cc:98
static G4ThreeVector ClosestPointOnSegment(const G4ThreeVector &P, const G4ThreeVector &A, const G4ThreeVector &B)
Definition: G4GeomTools.cc:663
static G4bool CheckSnip(const G4TwoVectorList &contour, G4int a, G4int b, G4int c, G4int n, const G4int *V)
Definition: G4GeomTools.cc:277
int G4int
Definition: G4Types.hh:78
std::vector< G4TwoVector > G4TwoVectorList
Definition: G4GeomTools.hh:50
double C(double temp)
static G4double QuadArea(const G4TwoVector &A, const G4TwoVector &B, const G4TwoVector &C, const G4TwoVector &D)
Definition: G4GeomTools.cc:70
static void RemoveRedundantVertices(G4TwoVectorList &polygon, std::vector< G4int > &iout, G4double tolerance=0)
Definition: G4GeomTools.cc:311
Char_t n[5]
static G4bool SphereExtent(G4double rmin, G4double rmax, G4double startTheta, G4double delTheta, G4double startPhi, G4double delPhi, G4ThreeVector &pmin, G4ThreeVector &pmax)
Definition: G4GeomTools.cc:795
static G4ThreeVector TriangleAreaNormal(const G4ThreeVector &A, const G4ThreeVector &B, const G4ThreeVector &C)
Definition: G4GeomTools.cc:603
double B(double temperature)
static G4bool PointInPolygon(const G4TwoVector &P, const G4TwoVectorList &Polygon)
Definition: G4GeomTools.cc:151
static G4double PolygonArea(const G4TwoVectorList &polygon)
Definition: G4GeomTools.cc:82