EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
egs_circle.h
Go to the documentation of this file.
1 /*
2 ###############################################################################
3 #
4 # EGSnrc egs++ circle shape headers
5 # Copyright (C) 2015 National Research Council Canada
6 #
7 # This file is part of EGSnrc.
8 #
9 # EGSnrc is free software: you can redistribute it and/or modify it under
10 # the terms of the GNU Affero General Public License as published by the
11 # Free Software Foundation, either version 3 of the License, or (at your
12 # option) any later version.
13 #
14 # EGSnrc is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 # FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
17 # more details.
18 #
19 # You should have received a copy of the GNU Affero General Public License
20 # along with EGSnrc. If not, see <http://www.gnu.org/licenses/>.
21 #
22 ###############################################################################
23 #
24 # Author: Iwan Kawrakow, 2005
25 #
26 # Contributors:
27 #
28 ###############################################################################
29 */
30 
31 
37 #ifndef EGS_CIRCLE_
38 #define EGS_CIRCLE_
39 
40 #include "egs_shapes.h"
41 #include "egs_rndm.h"
42 #include "egs_math.h"
43 
44 #ifdef WIN32
45 
46  #ifdef BUILD_CIRCLE_DLL
47  #define EGS_CIRCLE_EXPORT __declspec(dllexport)
48  #else
49  #define EGS_CIRCLE_EXPORT __declspec(dllimport)
50  #endif
51  #define EGS_CIRCLE_LOCAL
52 
53 #else
54 
55  #ifdef HAVE_VISIBILITY
56  #define EGS_CIRCLE_EXPORT __attribute__ ((visibility ("default")))
57  #define EGS_CIRCLE_LOCAL __attribute__ ((visibility ("hidden")))
58  #else
59  #define EGS_CIRCLE_EXPORT
60  #define EGS_CIRCLE_LOCAL
61  #endif
62 
63 #endif
64 
87 class EGS_CIRCLE_EXPORT EGS_CircleShape : public EGS_SurfaceShape {
88 
89 public:
90 
93  EGS_CircleShape(EGS_Float Xo, EGS_Float Yo, EGS_Float R, EGS_Float R_i = 0,
94  const string &Name="",EGS_ObjectFactory *f=0) :
95  EGS_SurfaceShape(Name,f), xo(Xo), yo(Yo), ro(R_i), dr(R-R_i) {
96  otype = "circle";
97  if (dr < 0) {
98  ro = R;
99  dr = R_i - R;
100  }
101  A = M_PI*dr*(dr + 2*ro);
102  };
103  ~EGS_CircleShape() {};
105  EGS_Float r = ro + dr*sqrt(rndm->getUniform());
106  EGS_Float cphi, sphi;
107  rndm->getAzimuth(cphi,sphi);
108  return EGS_Vector(xo + r*cphi, yo + r*sphi, 0);
109  };
110 
111 protected:
112 
113  EGS_Float xo, yo, ro, dr;
114 };
115 
116 #endif
A surface shape.
Definition: egs_shapes.h:252
EGS_CircleShape(EGS_Float Xo, EGS_Float Yo, EGS_Float R, EGS_Float R_i=0, const string &Name="", EGS_ObjectFactory *f=0)
Conctruct a circle with midpoint given by Xo and Yo, radius R and innder radius R_i.
Definition: egs_circle.h:93
A class representing 3D vectors.
Definition: egs_vector.h:56
void getAzimuth(EGS_Float &cphi, EGS_Float &sphi)
Sets cphi and sphi to the cosine and sine of a random angle uniformely distributed between 0 and ...
Definition: egs_rndm.h:138
virtual EGS_Vector getPoint(EGS_RandomGenerator *rndm)
Sample and return a random 3D vector.
Definition: egs_shapes.h:149
Base random number generator class. All random number generators should be derived from this class...
Definition: egs_rndm.h:67
EGS_RandomGenerator class header file.
EGS_BaseShape and shape classes header file.
An object factory.
Attempts to fix broken math header files.
EGS_Float getUniform()
Returns a random number uniformly distributed between zero (inclusive) and 1 (exclusive).
Definition: egs_rndm.h:103
A circle shape.
Definition: egs_circle.h:87