121 otype =
"base_shape";
138 return (*T)*getPoint(rndm);
141 return getPoint(rndm);
152 egsFatal(
"You need to implement the getPoint function in your "
232 egsFatal(
"getPointSourceDirection: you have to implement this "
233 "method for the %s shape if you want to use it\n",otype.c_str());
242 virtual EGS_Float
area()
const {
294 EGS_Float d2i = 1/u.length2(), di = sqrt(d2i);
296 wt = A*fabs(u.
z)*d2i;
374 EGS_Float ax, ay,
az;
445 else if (eta < 2*(ax*ay + ax*az)) {
448 if (eta < 2*ax*ay + ax*az) {
458 eta -= 2*(ax*ay + ax*az);
471 EGS_Float d2 = u.length2(), d = sqrt(d2);
473 wt *= (area()/(d2*d));
480 return 2*(ax*ay + ax*az + ay*az);
536 EGS_Float sint = sqrt(1-cost*cost);
538 EGS_Float cphi, sphi;
540 return xo +
EGS_Vector(r1*cphi,r1*sphi,R*r*cost);
563 EGS_Float sint = 1-cost*cost;
566 EGS_Float cphi, sphi;
576 u = (x + this->xo) - xo;
577 EGS_Float di = 1/u.length();
579 wt = u*x*4*M_PI*R*di*di;
630 while (x*x + y*y > 1);
637 EGS_Float phi = phi_min*(1-eta) + phi_max*eta;
651 phi_min(0), phi_max(2*M_PI), has_phi(false) {
659 phi_min(0), phi_max(2*M_PI), has_phi(false) {
661 if (xo.length2() >
epsilon || !rmat.isI()) {
672 phi_min(0), phi_max(2*M_PI), has_phi(false) {
683 if (Phi_min < Phi_max) {
691 if (phi_max - phi_min < 1.99999*M_PI) {
704 getPointInCircle(rndm,x,y);
741 getPointInCircle(rndm,x.
x,x.
y);
760 u = (x+this->xo) - xo;
761 EGS_Float d2 = u.length2(), d = sqrt(d2);
771 return 2*M_PI*R*(R+h);
Base shape class. All shapes in the EGSnrc C++ class library are derived from EGS_BaseShape.
void setTransformation(EGS_AffineTransform *t)
Set the transformation attached to this shape.
virtual void getPointSourceDirection(const EGS_Vector &xo, EGS_RandomGenerator *rndm, EGS_Vector &u, EGS_Float &wt)
virtual EGS_Float area() const
EGS_AffineTransform * T
The affine transformation attached to the shape.
EGS_BaseShape(const string &Name="", EGS_ObjectFactory *f=0)
Construct a shape named Name.
virtual ~EGS_BaseShape()
Destructor. Deletes T if it is not null.
virtual EGS_Vector getPoint(EGS_RandomGenerator *rndm)
Sample and return a random 3D vector.
virtual void updatePosition(EGS_Float time)
Update the position of the shape if it is in motion.
const EGS_AffineTransform * getTransform() const
Get a pointer to the affine transformation attached to this shape.
virtual EGS_Vector getRandomPoint(EGS_RandomGenerator *rndm)
Returns a random 3D vector.
virtual bool supportsDirectionMethod() const
void getPointSourceDirection(const EGS_Vector &Xo, EGS_RandomGenerator *rndm, EGS_Vector &u, EGS_Float &wt)
Sets the direction u by picking a random point uniformly the on the box surface.
EGS_Float az
The box size.
EGS_Vector getPoint(EGS_RandomGenerator *rndm)
Returns a point uniformly distributed within the box.
EGS_BoxShape(const string &Name="", EGS_ObjectFactory *f=0)
Create a box shape with unit size.
EGS_BoxShape(EGS_Float A, const EGS_AffineTransform *t=0, const string &Name="", EGS_ObjectFactory *f=0)
Create a cube with size A.
EGS_BoxShape(EGS_Float Ax, EGS_Float Ay, EGS_Float Az, const EGS_AffineTransform *t=0, const string &Name="", EGS_ObjectFactory *f=0)
Create a box shape with size Ax,Ay,Az.
bool supportsDirectionMethod() const
Returns true. (It is easy to implement the getPointSourceDirection() method for a box....
EGS_Float area() const
Returns the box surface area.
~EGS_BoxShape()
Destructor. Does nothing.
void getPointSourceDirection(const EGS_Vector &Xo, EGS_RandomGenerator *rndm, EGS_Vector &u, EGS_Float &wt)
Sets the direction u by picking a random point uniformly on the cylinder surface.
bool supportsDirectionMethod() const
Returns true. (It is easy to implement the getPointSourceDirection() method for a cylinder....
EGS_Float getHeight() const
void getPointInCircle(EGS_RandomGenerator *rndm, EGS_Float &x, EGS_Float &y)
Get a point uniformly distributed within a circle.
void setPhiRange(EGS_Float Phi_min, EGS_Float Phi_max)
EGS_Float h
Cylinder height.
EGS_Float getRadius() const
EGS_CylinderShape(EGS_Float r, EGS_Float H, const EGS_AffineTransform *t, const string &Name="", EGS_ObjectFactory *f=0)
EGS_Vector a
Cylinder axis.
EGS_CylinderShape(const string &Name="", EGS_ObjectFactory *f=0)
bool has_phi
True, if azimuthal range restricted.
EGS_Vector getPoint(EGS_RandomGenerator *rndm)
Samples and returns a point uniformly distributed within the cylinder.
EGS_Float R
Cylinder radius.
EGS_Float area() const
Returns the cylinder surface area.
virtual EGS_Object * createObject(EGS_Input *inp)
Create an object from the infromation pointed to by inp.
A point shape. This is the simplest shape possible: it simply always returns the same point.
EGS_Vector xo
The point position.
EGS_Vector getPoint(EGS_RandomGenerator *)
Returns a fixed point.
EGS_PointShape(const EGS_Vector &Xo=EGS_Vector(), const string &Name="", EGS_ObjectFactory *f=0)
Construct a point shape located at Xo.
Base random number generator class. All random number generators should be derived from this class.
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 .
EGS_Float getUniform()
Returns a random number uniformly distributed between zero (inclusive) and 1 (exclusive).
A class for vector rotations.
EGS_SphereShape(const string &Name="", EGS_ObjectFactory *f=0)
Construct a sphere of unit radius about the origin.
EGS_SphereShape(EGS_Float r, const EGS_Vector &Xo=EGS_Vector(0, 0, 0), const string &Name="", EGS_ObjectFactory *f=0)
Construct a sphere of radius r with midpoint Xo.
bool supportsDirectionMethod() const
Returns true. (It is easy to implement the getPointSourceDirection() method for a sphere....
void getPointSourceDirection(const EGS_Vector &Xo, EGS_RandomGenerator *rndm, EGS_Vector &u, EGS_Float &wt)
Sets the direction u by picking a random point uniformly on the sphere surface.
EGS_Float area() const
Returns the sphere surface area.
EGS_Vector getPoint(EGS_RandomGenerator *rndm)
Returns a random point within the sphere.
EGS_Float R
The sphere radius.
EGS_Vector xo
The sphere midpoint.
EGS_SurfaceShape(const string &Name="", EGS_ObjectFactory *f=0)
Construct a surface shape named Name.
~EGS_SurfaceShape()
Destructor. Does nothing.
void getPointSourceDirection(const EGS_Vector &Xo, EGS_RandomGenerator *rndm, EGS_Vector &u, EGS_Float &wt)
Get a random direction given a source position Xo.
EGS_Float area() const
Returns the area of this surface shape.
bool supportsDirectionMethod() const
Always returns true. Shapes derived from this class must implement the getPoint() method to return po...
A class representing 3D vectors.
#define EGS_EXPORT
Export symbols from the egspp library.
EGS_Object and EGS_ObjectFactory class header file.
EGS_RandomGenerator class header file.
EGS_Vector methods for the manipulation of 3D vectors in cartesian co-ordinates.
EGS_InfoFunction EGS_EXPORT egsFatal
Always use this function for reporting fatal errors.
const EGS_Float epsilon
The epsilon constant for floating point comparisons.