Garfield++ v2r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
Heed::circumf Class Reference

Circumference, determined by point (center), normal vector, and radius. More...

#include <circumf.h>

+ Inheritance diagram for Heed::circumf:

Public Member Functions

 circumf ()
 Default constructor.
 
 circumf (const point &fpiv, const vec &fdir, vfloat frad)
 Constructor.
 
 circumf (const circumf &f)
 
circumfoperator= (const circumf &f)
 
virtual ~circumf ()
 Destructor.
 
point Gpiv () const
 
vec Gdir () const
 
vfloat Grad () const
 
int check_point_in (const point &fp, vfloat prec) const
 Return 1 if point on the circumference.
 
int cross (const plane &pn, point pt[2], vfloat prec) const
 
- Public Member Functions inherited from Heed::absref
virtual ~absref ()
 Destructor.
 
virtual void down (const abssyscoor *fasc)
 Convert numbering representation of object to basical system of fasc.
 
virtual void up (const abssyscoor *fasc)
 Convert numbering representation of objects to new system.
 
virtual void turn (const vec &dir, vfloat angle)
 Turn around axis doing via center of coordinate system along dir.
 
virtual void shift (const vec &dir)
 

Protected Member Functions

virtual void get_components (ActivePtr< absref_transmit > &aref_tran)
 

Protected Attributes

point piv
 Central point, pivot.
 
vec dir
 
vfloat rad
 Radius, >0.
 

Static Protected Attributes

static absrefabsref::*[2] aref
 

Friends

int operator== (const circumf &f1, const circumf &f2)
 
int operator!= (const circumf &f1, const circumf &f2)
 
bool apeq (const circumf &f1, const circumf &f2, vfloat prec)
 
std::ostream & operator<< (std::ostream &file, const circumf &f)
 

Detailed Description

Circumference, determined by point (center), normal vector, and radius.

Definition at line 23 of file circumf.h.

Constructor & Destructor Documentation

◆ circumf() [1/3]

Heed::circumf::circumf ( )

Default constructor.

Definition at line 20 of file circumf.cpp.

20: piv(), dir(), rad(0) {}
vfloat rad
Radius, >0.
Definition: circumf.h:64
point piv
Central point, pivot.
Definition: circumf.h:59

◆ circumf() [2/3]

Heed::circumf::circumf ( const point fpiv,
const vec fdir,
vfloat  frad 
)

Constructor.

Definition at line 21 of file circumf.cpp.

22 : piv(fpiv), dir(), rad(frad) {
23 pvecerror("circumf(...)");
24 check_econd11(fdir.length(), == 0, mcerr);
25 dir = unit_vec(fdir);
26}
#define check_econd11(a, signb, stream)
Definition: FunNameStack.h:155
#define mcerr
Definition: prstream.h:128
#define pvecerror(string)
Definition: vec.h:29

◆ circumf() [3/3]

Heed::circumf::circumf ( const circumf f)

Definition at line 27 of file circumf.cpp.

28 : absref(f), piv(f.piv), dir(f.dir), rad(f.rad) {}

◆ ~circumf()

virtual Heed::circumf::~circumf ( )
inlinevirtual

Destructor.

Definition at line 37 of file circumf.h.

37{}

Member Function Documentation

◆ check_point_in()

int Heed::circumf::check_point_in ( const point fp,
vfloat  prec 
) const

Return 1 if point on the circumference.

Definition at line 50 of file circumf.cpp.

50 {
51 // returns 1 if point on the circumference
52 pvecerror("int circumf::check_point_in(const point &fp, vfloat prec) const");
53 vec d = fp - piv;
54 if (check_perp(d, dir, prec) != 1) return 0;
55 if (apeq(d.length(), rad)) return 1;
56 return 0;
57}
friend bool apeq(const circumf &f1, const circumf &f2, vfloat prec)
Definition: circumf.cpp:44

◆ cross()

int Heed::circumf::cross ( const plane pn,
point  pt[2],
vfloat  prec 
) const

Definition at line 58 of file circumf.cpp.

58 {
59 pvecerror("int circumf::cross(const plane& pn, point pt[2]) const");
60 if (pn.distance(piv) > rad) return 0; // to avoid cross at very far pn
61 plane pnc(piv, dir);
62 straight sl(pnc, pn);
63 if (vecerror == 3) {
64 vecerror = 0;
65 return -1;
66 }
67 if (vecerror == 2) {
68 vecerror = 0;
69 return 0;
70 }
71 point closest_pt;
72 vfloat d = sl.distance(piv, closest_pt);
73 if (apeq(d, rad, prec)) {
74 pt[0] = closest_pt;
75 return 1;
76 }
77 if (d > rad) return 0;
78 vfloat cat = sqrt(rad * rad - d * d);
79 pt[0] = closest_pt + cat * sl.Gdir();
80 pt[1] = closest_pt - cat * sl.Gdir();
81 return 2;
82}
int vecerror
Definition: vec.cpp:29
DoubleAc sqrt(const DoubleAc &f)
Definition: DoubleAc.cpp:314
double vfloat
Definition: vfloat.h:16

Referenced by Heed::splane::range().

◆ Gdir()

vec Heed::circumf::Gdir ( ) const
inline

Definition at line 45 of file circumf.h.

45{ return dir; }

Referenced by Heed::splane::range().

◆ get_components()

void Heed::circumf::get_components ( ActivePtr< absref_transmit > &  aref_tran)
protectedvirtual

Reimplemented from Heed::absref.

Definition at line 30 of file circumf.cpp.

30 {
31 aref_tran.pass(new absref_transmit(2, aref));
32}
static absrefabsref::*[2] aref
Definition: circumf.h:67

◆ Gpiv()

point Heed::circumf::Gpiv ( ) const
inline

Definition at line 44 of file circumf.h.

44{ return piv; }

Referenced by Heed::splane::range().

◆ Grad()

vfloat Heed::circumf::Grad ( ) const
inline

Definition at line 46 of file circumf.h.

46{ return rad; }

Referenced by Heed::splane::range().

◆ operator=()

circumf & Heed::circumf::operator= ( const circumf f)
inline

Definition at line 30 of file circumf.h.

30 {
31 piv = f.piv;
32 dir = f.dir;
33 rad = f.rad;
34 return *this;
35 }

Friends And Related Function Documentation

◆ apeq

bool apeq ( const circumf f1,
const circumf f2,
vfloat  prec 
)
friend

Definition at line 44 of file circumf.cpp.

44 {
45 pvecerror("bool apeq(const circumf &f1, const circumf &f2, vfloat prec)");
46 if (check_par(f1.dir, f2.dir, prec) == 0) return false;
47 return apeq(f1.piv, f2.piv, prec) && apeq(f1.rad, f2.rad, prec);
48}

Referenced by check_point_in(), and cross().

◆ operator!=

int operator!= ( const circumf f1,
const circumf f2 
)
friend

Definition at line 39 of file circumf.h.

39 {
40 return f1 == f2 ? 0 : 1;
41 }

◆ operator<<

std::ostream & operator<< ( std::ostream &  file,
const circumf f 
)
friend

Definition at line 84 of file circumf.cpp.

84 {
85 Ifile << "circumf(erence):\n";
86 indn.n += 2;
87 Ifile << "rad=" << f.rad << '\n';
88 file << f.piv << f.dir;
89 indn.n -= 2;
90 return file;
91}
indentation indn
Definition: prstream.cpp:15
#define Ifile
Definition: prstream.h:196

◆ operator==

int operator== ( const circumf f1,
const circumf f2 
)
friend

Definition at line 34 of file circumf.cpp.

34 {
35 pvecerror("int operator==(const circumf &f1, const circumf &f2)");
36
37 if (!(f1.dir == f2.dir || f1.dir == -f2.dir)) return 0;
38 if (f1.piv == f2.piv && f1.rad == f2.rad)
39 return 1;
40 else
41 return 0;
42}

Member Data Documentation

◆ aref

absref absref::* Heed::circumf::aref
staticprotected
Initial value:
= {(absref absref::*)&circumf::piv,
(absref absref::*)&circumf::dir}

Definition at line 67 of file circumf.h.

Referenced by get_components().

◆ dir

vec Heed::circumf::dir
protected

Normal direction, unit vector. Circles with dir and -dir are considered the same.

Definition at line 62 of file circumf.h.

Referenced by check_point_in(), circumf(), cross(), Gdir(), and operator=().

◆ piv

point Heed::circumf::piv
protected

Central point, pivot.

Definition at line 59 of file circumf.h.

Referenced by check_point_in(), cross(), Gpiv(), and operator=().

◆ rad

vfloat Heed::circumf::rad
protected

Radius, >0.

Definition at line 64 of file circumf.h.

Referenced by check_point_in(), cross(), Grad(), and operator=().


The documentation for this class was generated from the following files: