119 otype =
"base_shape";
136 return (*T)*getPoint(rndm);
139 return getPoint(rndm);
150 egsFatal(
"You need to implement the getPoint function in your "
222 egsFatal(
"getPointSourceDirection: you have to implement this "
223 "method for the %s shape if you want to use it\n",otype.c_str());
232 virtual EGS_Float
area()
const {
280 EGS_Float d2i = 1/u.length2(), di = sqrt(d2i);
282 wt = A*fabs(u.
z)*d2i;
360 EGS_Float ax, ay,
az;
431 else if (eta < 2*(ax*ay + ax*az)) {
434 if (eta < 2*ax*ay + ax*az) {
444 eta -= 2*(ax*ay + ax*az);
457 EGS_Float d2 = u.length2(), d = sqrt(d2);
459 wt *= (
area()/(d2*d));
466 return 2*(ax*ay + ax*az + ay*az);
522 EGS_Float sint = sqrt(1-cost*cost);
524 EGS_Float cphi, sphi;
526 return xo +
EGS_Vector(r1*cphi,r1*sphi,R*r*cost);
549 EGS_Float sint = 1-cost*cost;
552 EGS_Float cphi, sphi;
562 u = (x + this->xo) - xo;
563 EGS_Float di = 1/u.length();
565 wt = u*x*4*M_PI*R*di*di;
616 while (x*x + y*y > 1);
623 EGS_Float phi = phi_min*(1-eta) + phi_max*eta;
637 phi_min(0), phi_max(2*M_PI), has_phi(false) {
645 phi_min(0), phi_max(2*M_PI), has_phi(false) {
647 if (xo.length2() >
epsilon || !rmat.isI()) {
658 phi_min(0), phi_max(2*M_PI), has_phi(false) {
669 if (Phi_min < Phi_max) {
677 if (phi_max - phi_min < 1.99999*M_PI) {
690 getPointInCircle(rndm,x,y);
727 getPointInCircle(rndm,x.
x,x.
y);
746 u = (x+this->xo) - xo;
747 EGS_Float d2 = u.length2(), d = sqrt(d2);
757 return 2*M_PI*R*(R+h);
#define EGS_EXPORT
Export symbols from the egspp library.
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.
EGS_Vector getPoint(EGS_RandomGenerator *)
Returns a fixed point.
~EGS_BoxShape()
Destructor. Does nothing.
EGS_Vector getPoint(EGS_RandomGenerator *rndm)
Returns a point uniformely distributed within the box.
EGS_Vector xo
The sphere midpoint.
EGS_Float getRadius() const
void getPointInCircle(EGS_RandomGenerator *rndm, EGS_Float &x, EGS_Float &y)
Get a point uniformly distributed within a circle.
virtual EGS_Vector getRandomPoint(EGS_RandomGenerator *rndm)
Returns a random 3D vector.
bool supportsDirectionMethod() const
Returns true. (It is easy to implement the getPointSourceDirection() method for a cylinder...
EGS_SurfaceShape(const string &Name="", EGS_ObjectFactory *f=0)
Construct a surface shape named Name.
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. ...
A class for vector rotations.
~EGS_SurfaceShape()
Destructor. Does nothing.
EGS_SphereShape(const string &Name="", EGS_ObjectFactory *f=0)
Construct a sphere of unit radius about the origin.
EGS_Vector methods for the manipulation of 3D vectors in cartesian co-ordinates.
EGS_CylinderShape(EGS_Float r, EGS_Float H, const EGS_AffineTransform *t, const string &Name="", EGS_ObjectFactory *f=0)
A class representing 3D vectors.
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 ...
virtual EGS_Object * createObject(EGS_Input *inp)
Create an object from the infromation pointed to by inp.
Base shape class. All shapes in the EGSnrc C++ class library are derived from EGS_BaseShape.
EGS_Float R
Cylinder radius.
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.
void getPointSourceDirection(const EGS_Vector &Xo, EGS_RandomGenerator *rndm, EGS_Vector &u, EGS_Float &wt)
Sets the direction u by picking a random point uniformely the on the box surface. ...
EGS_Vector xo
The point position.
void setTransformation(EGS_AffineTransform *t)
Set the transformation attached to this shape.
virtual EGS_Vector getPoint(EGS_RandomGenerator *rndm)
Sample and return a random 3D vector.
Base random number generator class. All random number generators should be derived from this class...
virtual EGS_Float area() const
const EGS_AffineTransform * getTransform() const
Get a pointer to the affine transformation attached to this shape.
virtual bool supportsDirectionMethod() const
EGS_InfoFunction EGS_EXPORT egsFatal
Always use this function for reporting fatal errors.
A point shape. This is the simplest shape possible: it simply always returns the same point...
EGS_RandomGenerator class header file.
virtual void getPointSourceDirection(const EGS_Vector &xo, EGS_RandomGenerator *rndm, EGS_Vector &u, EGS_Float &wt)
EGS_Vector getPoint(EGS_RandomGenerator *rndm)
Samples and returns a point uniformly distributed within the cylinder.
EGS_Float az
The box size.
EGS_Float R
The sphere radius.
EGS_Float h
Cylinder height.
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_Float area() const
Returns the cylinder surface area.
EGS_Vector a
Cylinder axis.
void setPhiRange(EGS_Float Phi_min, EGS_Float Phi_max)
void getPointSourceDirection(const EGS_Vector &Xo, EGS_RandomGenerator *rndm, EGS_Vector &u, EGS_Float &wt)
Sets the direction u by picking a random point uniformely on the sphere surface.
EGS_Float getUniform()
Returns a random number uniformly distributed between zero (inclusive) and 1 (exclusive).
bool supportsDirectionMethod() const
Always returns true. Shapes derived from this class must implement the getPoint() method to return po...
EGS_Vector getPoint(EGS_RandomGenerator *rndm)
Returns a random point within the sphere.
EGS_BaseShape(const string &Name="", EGS_ObjectFactory *f=0)
Construct a shape named Name.
EGS_Float getHeight() const
EGS_PointShape(const EGS_Vector &Xo=EGS_Vector(), const string &Name="", EGS_ObjectFactory *f=0)
Construct a point shape located at Xo.
const EGS_Float epsilon
The epsilon constant for floating point comparisons.
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_Object and EGS_ObjectFactory class header file.
EGS_CylinderShape(const string &Name="", EGS_ObjectFactory *f=0)
EGS_Float area() const
Returns the box surface area.
EGS_Float area() const
Returns the area of this surface shape.
virtual ~EGS_BaseShape()
Destructor. Deletes T if it is not null.
bool has_phi
True, if azimuthal range restricted.
bool supportsDirectionMethod() const
Returns true. (It is easy to implement the getPointSourceDirection() method for a box...
EGS_Float area() const
Returns the sphere surface area.
bool supportsDirectionMethod() const
Returns true. (It is easy to implement the getPointSourceDirection() method for a sphere...