LCOV - code coverage report
Current view: top level - include/crpropa - Geometry.h (source / functions) Coverage Total Hit
Test: coverage.info.cleaned Lines: 75.0 % 4 3
Test Date: 2026-07-13 06:03:10 Functions: 0.0 % 1 0

            Line data    Source code
       1              : #ifndef CRPROPA_GEOMETRY_H
       2              : #define CRPROPA_GEOMETRY_H
       3              : 
       4              : #include <string>
       5              : 
       6              : #include "crpropa/Candidate.h"
       7              : #include "crpropa/Vector3.h"
       8              : #include "crpropa/Referenced.h"
       9              : 
      10              : namespace crpropa {
      11              : /**
      12              :  * \addtogroup Core
      13              :  * @{
      14              :  */
      15              : 
      16              : /**
      17              :  @class Surface
      18              :  @brief A geometrical surface
      19              : 
      20              :  Defines a surface. Can be queried if the candidate has crossed the surface in the last step.
      21              :  */
      22              : class Surface : public Referenced {
      23              : public:
      24              :         /** Returns the distance of a point to the surface. Negative on the one side,
      25              :          positive on the other. For closed surfaces it is negative on the inside.
      26              :          @param point   vector corresponding to the point to which compute the distance
      27              :          */
      28              :         virtual double distance(const Vector3d& point) const = 0;
      29              :         /** Returns the normal to the surface at a point. Negative on the one side,
      30              :          positive on the other. For closed surfaces it is negative on the inside.
      31              :          @param point   vector corresponding to the point to which compute the normal vector
      32              :          */
      33              :         virtual Vector3d normal(const Vector3d& point) const = 0;
      34            0 :         virtual std::string getDescription() const {return "Surface without description.";};
      35              : };
      36              : 
      37              : 
      38              : /**
      39              :  @class Plane
      40              :  @brief A plane given by a point x0 and two axes v1 and v2 with normal n = v1.cross(v2) or the normal n. Note that distance is negative on one side of the plane and positive on the other, depending on the orientation of the normal vector.
      41              :  */
      42            1 : class Plane: public Surface {
      43              : private:
      44              :         Vector3d x0, n;
      45              : public:
      46              :         /** Constructor
      47              :          * The plane is constructed from the given point x0 along the two axes v1 and v2
      48              :          * @param x0  Point where to start construction
      49              :          * @param v1  First axis of plane
      50              :          * @param v2  Second axis of plane
      51              :          */
      52              :         Plane(const Vector3d& x0, const Vector3d& v1,const Vector3d& v2);
      53              :         /** Constructor
      54              :          * The plane is constucted from the given point x0 perpendicular on the normal n
      55              :          * @param x0  Point where to start construction
      56              :          * @param n  Normal
      57              :          */
      58              :         Plane(const Vector3d& x0, const Vector3d& n);
      59              :         /**
      60              :          * The distance is calculated with the normal n: return n.dot(x-x0);
      61              :          */
      62              :         virtual double distance(const Vector3d &x) const;
      63              :         /// returns the normal of the plain independent of the point
      64              :         virtual Vector3d normal(const Vector3d& point=Vector3d(0,0,0)) const;
      65              :         virtual std::string getDescription() const;
      66              : };
      67              : 
      68              : 
      69              : /**
      70              :  @class Sphere
      71              :  @brief A sphere around point _center with radius _radius.
      72              :  */
      73            1 : class Sphere: public Surface {
      74              : private:
      75              :         Vector3d center;
      76              :         double radius;
      77              : public:
      78              :         /** Constructor
      79              :          * @param center  Center point of the sphere
      80              :          * @param radius  Radius of the sphere
      81              :          */
      82              :         Sphere(const Vector3d& center, double radius);
      83              :         /**
      84              :          * Distance to the sphere, negative on the inside
      85              :          * @param point  Point to calculate the distance from the sphere from
      86              :          */
      87              :         virtual double distance(const Vector3d &point) const;
      88              :         /** Returns the normal to the surface at a point. Negative on the inside,
      89              :          positive on the other.
      90              :          @param point  Vector corresponding to the point to which compute the normal vector
      91              :          */
      92              :         virtual Vector3d normal(const Vector3d& point) const;
      93              :         virtual std::string getDescription() const;
      94              : };
      95              : 
      96              : 
      97              : /**
      98              :  @class ParaxialBox
      99              :  @brief A box with perpendicular surfaces aligned to the x,y,z-axes.
     100              :  */
     101            1 : class ParaxialBox: public Surface {
     102              : private:
     103              :         Vector3d corner, size;
     104              : public:
     105              :         /** Constructor
     106              :          * @param corner  The Box will stretch beginning from corner in positive x,y,z direction
     107              :          * @param size  The size of the box (all sides are equal)
     108              :          */
     109              :         ParaxialBox(const Vector3d& corner, const Vector3d& size);
     110              :         /// Return distance to the Box for given point
     111              :         virtual double distance(const Vector3d &point) const;
     112              :         /// Return normal to the closest surface for given point
     113              :         virtual Vector3d normal(const Vector3d& point) const;
     114              :         virtual std::string getDescription() const;
     115              : };
     116              : 
     117              : 
     118              : /** @}*/
     119              : } // namespace crpropa
     120              : 
     121              : #endif // CRPROPA_GEOMETRY_H
        

Generated by: LCOV version 2.0-1