Garfield++ v2r0
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

Plane, defined by defined by a point and a vector normal to the plane. More...

#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 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
 Origin point, pivot.
 
vec dir
 Direction of normal, unit vector.
 

Static Protected Attributes

static absrefabsref::*[2] aref
 

Friends

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

Detailed Description

Plane, defined by defined by a point and a vector normal to the plane.

Definition at line 24 of file plane.h.

Constructor & Destructor Documentation

◆ plane() [1/4]

Heed::plane::plane ( )
inline

Definition at line 40 of file plane.h.

40: piv(), dir() { ; }
point piv
Origin point, pivot.
Definition: plane.h:27
vec dir
Direction of normal, unit vector.
Definition: plane.h:29

◆ plane() [2/4]

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

Definition at line 41 of file plane.h.

41 : piv(fpiv), dir(unit_vec(fdir)) {
42 ;
43 }

◆ 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:29
#define pvecerror(string)
Definition: vec.h:29

◆ 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}

Member Function Documentation

◆ check_point_in()

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

Definition at line 67 of file plane.cpp.

67 {
68 pvecerror("int plane::check_point_in(point fp, vfloat prec)");
69 vfloat f = distance(fp);
70 if (f < prec) return 1;
71 return 0;
72}
vfloat distance(const point &fpt) const
Definition: plane.cpp:149
double vfloat
Definition: vfloat.h:16

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 93 of file plane.cpp.

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

◆ cross() [2/3]

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

Definition at line 114 of file plane.cpp.

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

◆ cross() [3/3]

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

Definition at line 74 of file plane.cpp.

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

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 149 of file plane.cpp.

149 {
150 pvecerror("vfloat plane::distance(point& fpt)");
151 if (fpt == piv) return 0.0;
152 vec v = fpt - piv;
153 return fabs(v * dir); // relys that dir is unit length vector
154}
DoubleAc fabs(const DoubleAc &f)
Definition: DoubleAc.h:615

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

◆ Gdir()

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

Definition at line 33 of file plane.h.

33{ return dir; }

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

◆ get_components()

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

Reimplemented from Heed::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:37

◆ Gpiv()

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

Definition at line 32 of file plane.h.

32{ return piv; }

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 50 of file plane.h.

50 {
51 piv = fpl.piv;
52 dir = fpl.dir;
53 return *this;
54 }

Friends And Related Function Documentation

◆ apeq

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

Definition at line 60 of file plane.cpp.

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

◆ operator!=

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

Definition at line 57 of file plane.h.

57 {
58 return pl1 == pl2 ? 0 : 1;
59 }

◆ operator<<

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

Definition at line 156 of file plane.cpp.

156 {
157 Ifile << "plane:\n";
158 indn.n += 2;
159 file << pl.piv << pl.dir;
160 indn.n -= 2;
161 return file;
162}
indentation indn
Definition: prstream.cpp:15
#define Ifile
Definition: prstream.h:196

◆ 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:
= {(absref absref::*)&plane::piv,
(absref absref::*)&plane::dir}

Definition at line 37 of file plane.h.

Referenced by get_components().

◆ dir

vec Heed::plane::dir
protected

Direction of normal, unit vector.

Definition at line 29 of file plane.h.

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

◆ piv

point Heed::plane::piv
protected

Origin point, pivot.

Definition at line 27 of file plane.h.

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


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