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

#include <plane.h>

+ Inheritance diagram for Heed::plane:

Public Member Functions

point Gpiv (void) const
 
vec Gdir (void) const
 
 plane ()
 
 plane (const point &fpiv, const vec &fdir)
 
 plane (const straight &sl, const point &pt)
 
 plane (const straight &sl1, const straight &sl2, vfloat prec)
 
planeoperator= (const plane &fpl)
 
int check_point_in (const point &fp, vfloat prec) const
 
point cross (const straight &sl) const
 
straight cross (const plane &sl) const
 
int cross (const polyline &pll, point *crpt, int &qcrpt, polyline *crpll, int &qcrpll, vfloat prec) const
 
vfloat distance (const point &fpt) const
 
- Public Member Functions inherited from absref
virtual ~absref ()
 
virtual void down (const abssyscoor *fasc)
 
virtual void up (const abssyscoor *fasc)
 
virtual void turn (const vec &dir, vfloat angle)
 
virtual void shift (const vec &dir)
 

Protected Member Functions

virtual void get_components (ActivePtr< absref_transmit > &aref_tran)
 

Protected Attributes

point piv
 
vec dir
 

Static Protected Attributes

static absrefabsref::*[2] aref
 

Friends

int operator== (const plane &pl1, const plane &pl2)
 
int operator!= (const plane &pl1, const plane &pl2)
 
int apeq (const plane &pl1, const plane &pl2, vfloat prec)
 
int not_apeq (const plane &pl1, const plane &pl2, vfloat prec)
 
std::ostream & operator<< (std::ostream &file, const plane &s)
 

Detailed Description

Definition at line 26 of file plane.h.

Constructor & Destructor Documentation

◆ plane() [1/4]

Heed::plane::plane ( )
inline

Definition at line 44 of file plane.h.

44: piv(), dir() { ; }
point piv
Definition: plane.h:28
vec dir
Definition: plane.h:29

◆ plane() [2/4]

Heed::plane::plane ( const point fpiv,
const vec fdir 
)
inline

Definition at line 45 of file plane.h.

45 : piv(fpiv), dir(unit_vec(fdir)) {
46 ;
47 }

◆ plane() [3/4]

Heed::plane::plane ( const straight sl,
const point pt 
)

Definition at line 25 of file plane.cpp.

25 : piv(sl.Gpiv()), dir() {
26 pvecerror("plane::plane( const straight& sl, const point& pt)");
27 int i = sl.check_point_in(pt, 0.0);
28 if (i != 0)
29 vecerror = 1;
30 else
31 dir = unit_vec(sl.Gdir() || (pt - sl.Gpiv()));
32}
int vecerror
Definition: vec.cpp:31
#define pvecerror(string)
Definition: vec.h:52

◆ plane() [4/4]

Heed::plane::plane ( const straight sl1,
const straight sl2,
vfloat  prec 
)

Definition at line 33 of file plane.cpp.

34 : piv(sl1.Gpiv()), dir() {
36 "plane::plane( const straight& sl1, const straight& sl2, vfloat prec)");
37 point pt = sl1.cross(sl2, prec);
38 if (vecerror == 0) {
39 piv = pt;
40 dir = unit_vec(sl1.Gdir() || sl2.Gdir());
41 } else if (vecerror == 2) // different parallel lines
42 {
43 vecerror = 0;
44 dir = unit_vec(sl1.Gdir() || (sl2.Gpiv() - sl1.Gpiv()));
45 }
46 // otherwise vecerror != 0
47}
Definition: vec.h:477

Member Function Documentation

◆ check_point_in()

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

Definition at line 70 of file plane.cpp.

70 {
71 pvecerror("int plane::check_point_in(point fp, vfloat prec)");
72 vfloat f = distance(fp);
73 if (f < prec) return 1;
74 return 0;
75}
vfloat distance(const point &fpt) const
Definition: plane.cpp:153
double vfloat
Definition: vfloat.h:15

Referenced by Heed::polygon::check_point_in(), Heed::splane::check_point_inside(), and Heed::splane::check_point_inside1().

◆ cross() [1/3]

straight Heed::plane::cross ( const plane sl) const

Definition at line 96 of file plane.cpp.

96 {
97 pvecerror("point plane::cross(plane &pl)");
98 point plpiv = pl.Gpiv();
99 vec pldir = pl.Gdir();
100 vec a = dir || pldir; //direction of the overall straight lines
101 if (length(a) == 0) {
102 if (plpiv == piv || check_par(pldir, dir, 0.0) != 0) { // planes coinsides
103 vecerror = 3;
104 return straight();
105 } else {
106 vecerror = 2;
107 return straight();
108 }
109 }
110 a = unit_vec(a);
111 vec c = a || dir; //perpend. for ov. str.
112 straight st(piv, c);
113 point pt = pl.cross(st); //one point on ov. str.
114 return straight(pt, a); //overall straight
115}
Definition: vec.h:248

◆ cross() [2/3]

int Heed::plane::cross ( const polyline pll,
point crpt,
int &  qcrpt,
polyline crpll,
int &  qcrpll,
vfloat  prec 
) const

Definition at line 117 of file plane.cpp.

118 {
119 pvecerror("int plane::cross(polyline &pll, ...");
120
121 int n;
122 qcrpt = 0;
123 qcrpll = 0;
124 for (n = 0; n < pll.qsl; n++) {
125 point cpt = cross(pll.sl[n]);
126 if (vecerror == 3) // the line is in the plane
127 crpll[qcrpll++] = polyline(&(pll.pt[n]), 2);
128 else if (vecerror != 0)
129 vecerror = 0;
130 else {
131 vec v1 = cpt - pll.pt[n];
132 if (length(v1) < prec) {
133 if (n == 0) // otherwise it is probably included on the previous step
134 {
135 crpt[qcrpt++] = cpt;
136 }
137 } else {
138 vec v2 = cpt - pll.pt[n + 1];
139 if (length(v2) < prec)
140 crpt[qcrpt++] = cpt;
141 else if (check_par(v1, v2, prec) == -1)
142 // anti-parallel vectors, point inside borders
143 crpt[qcrpt++] = cpt;
144 }
145 }
146 }
147 if (qcrpt > 0 || qcrpll > 0)
148 return 1;
149 else
150 return 0;
151}
point cross(const straight &sl) const
Definition: plane.cpp:77

◆ cross() [3/3]

point Heed::plane::cross ( const straight sl) const

Definition at line 77 of file plane.cpp.

77 {
78 pvecerror("point plane::cross(straight &sl)");
79 point slpiv = sl.Gpiv();
80 vec sldir = sl.Gdir();
81 vfloat r = dir * sldir;
82 if (r == 0.0) {
83 if (slpiv == piv || check_perp((piv - slpiv), dir, 0.0) == 1) {
84 // Line is in plane
85 vecerror = 3;
86 } else {
87 vecerror = 2;
88 }
89 return point();
90 }
91
92 vfloat t = (piv.v - slpiv.v) * dir;
93 return point(slpiv.v + t / r * sldir);
94}
vec v
Definition: vec.h:479

Referenced by cross(), Heed::splane::cross(), Heed::polygon::cross(), Heed::splane::range(), Heed::straight::straight(), and Heed::straight::vecdistance().

◆ distance()

vfloat Heed::plane::distance ( const point fpt) const

Definition at line 153 of file plane.cpp.

153 {
154 pvecerror("vfloat plane::distance(point& fpt)");
155 if (fpt == piv) return 0.0;
156 vec v = fpt - piv;
157 return abslt(v * dir); // relys that dir is unit length vector
158}
vfloat abslt(vfloat f)
Definition: vfloat.h:19

Referenced by check_point_in(), and Heed::circumf::cross().

◆ Gdir()

vec Heed::plane::Gdir ( void  ) const
inline

Definition at line 34 of file plane.h.

34 {
35 return dir;
36 }

Referenced by Heed::polygon::check_point_in(), and cross().

◆ get_components()

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

Reimplemented from absref.

Definition at line 21 of file plane.cpp.

21 {
22 aref_tran.pass(new absref_transmit(2, aref));
23}
static absrefabsref::*[2] aref
Definition: plane.h:40

◆ Gpiv()

point Heed::plane::Gpiv ( void  ) const
inline

Definition at line 31 of file plane.h.

31 {
32 return piv;
33 }

Referenced by Heed::splane::check_point_inside(), Heed::splane::check_point_inside1(), and cross().

◆ operator=()

plane & Heed::plane::operator= ( const plane fpl)
inline

Definition at line 54 of file plane.h.

54 {
55 piv = fpl.piv;
56 dir = fpl.dir;
57 return *this;
58 }

Friends And Related Function Documentation

◆ apeq

int apeq ( const plane pl1,
const plane pl2,
vfloat  prec 
)
friend

Definition at line 60 of file plane.cpp.

60 {
61 pvecerror("int apeq(const plane &pl1, const plane &pl2, vfloat prec)");
62 if (check_par(pl1.dir, pl2.dir, prec) == 0) return 0;
63 if (apeq(pl1.piv, pl2.piv, prec) == 1) return 1;
64 if (pl1.check_point_in(pl2.piv, prec) == 1)
65 return 1;
66 else
67 return 0;
68}
friend int apeq(const plane &pl1, const plane &pl2, vfloat prec)
Definition: plane.cpp:60

◆ not_apeq

int not_apeq ( const plane pl1,
const plane pl2,
vfloat  prec 
)
friend

Definition at line 65 of file plane.h.

65 {
66 return apeq(pl1, pl2, prec) ? 0 : 1;
67 }

◆ operator!=

int operator!= ( const plane pl1,
const plane pl2 
)
friend

Definition at line 61 of file plane.h.

61 {
62 return pl1 == pl2 ? 0 : 1;
63 }

◆ operator<<

std::ostream & operator<< ( std::ostream &  file,
const plane s 
)
friend

Definition at line 160 of file plane.cpp.

160 {
161 Ifile << "plane:\n";
162 indn.n += 2;
163 file << pl.piv << pl.dir;
164 indn.n -= 2;
165 return file;
166}
indentation indn
Definition: prstream.cpp:13
#define Ifile
Definition: prstream.h:207

◆ operator==

int operator== ( const plane pl1,
const plane pl2 
)
friend

Definition at line 49 of file plane.cpp.

49 {
50 pvecerror("int operator==(const plane &pl1, const plane &pl2)");
51
52 if (!(pl1.dir == pl2.dir || pl1.dir == -pl2.dir)) return 0;
53 if (pl1.piv == pl2.piv) return 1;
54 if (pl1.check_point_in(pl2.piv, 0) == 1)
55 return 1;
56 else
57 return 0;
58}

Member Data Documentation

◆ aref

absref absref::* Heed::plane::aref
staticprotected
Initial value:

Definition at line 40 of file plane.h.

Referenced by get_components().

◆ dir

vec Heed::plane::dir
protected

Definition at line 29 of file plane.h.

Referenced by cross(), distance(), Gdir(), operator=(), and plane().

◆ piv

point Heed::plane::piv
protected

Definition at line 28 of file plane.h.

Referenced by cross(), distance(), Gpiv(), operator=(), and plane().


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