Garfield++ 4.0
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 () const
 
vec Gdir () 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)
 
 plane (const plane &p)
 Copy constructor.
 
planeoperator= (const plane &fpl)
 Copy assignment operator.
 
int check_point_in (const point &fp, vfloat prec) const
 Return 1 if a point is in the plane (within precision prec).
 
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 absref_transmit get_components () override
 

Protected Attributes

point piv
 Origin point, pivot.
 
vec dir
 Direction of normal, unit vector.
 

Static Protected Attributes

static absref absref::* aref [2]
 

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/5]

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/5]

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)) {}

◆ plane() [3/5]

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

Definition at line 26 of file plane.cpp.

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

◆ plane() [4/5]

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

Definition at line 34 of file plane.cpp.

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

◆ plane() [5/5]

Heed::plane::plane ( const plane p)
inline

Copy constructor.

Definition at line 49 of file plane.h.

49: piv(p.piv), dir(p.dir) {}

Member Function Documentation

◆ check_point_in()

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

Return 1 if a point is in the plane (within precision prec).

Definition at line 68 of file plane.cpp.

68 {
69 pvecerror("int plane::check_point_in(point fp, vfloat prec)");
70 vfloat f = distance(fp);
71 if (f < prec) return 1;
72 return 0;
73}
vfloat distance(const point &fpt) const
Definition: plane.cpp:151
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

Determine the intersection with another plane. vecerror = 2: planes are parallel. vecerror = 3: planes are identical.

Definition at line 94 of file plane.cpp.

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

◆ cross() [2/3]

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

Definition at line 116 of file plane.cpp.

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

◆ cross() [3/3]

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

Figure out whether a straight line crosses the plane and return the intersection point if it does. vecerror = 2: line is parallel to the plane. vecerror = 3: line is in the plane.

Definition at line 75 of file plane.cpp.

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

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

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

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

◆ Gdir()

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

Definition at line 33 of file plane.h.

33{ return dir; }

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

◆ get_components()

absref_transmit Heed::plane::get_components ( )
overrideprotectedvirtual

Reimplemented from Heed::absref.

Definition at line 22 of file plane.cpp.

22 {
23 return absref_transmit(2, aref);
24}
static absref absref::* aref[2]
Definition: plane.h:37

◆ Gpiv()

point Heed::plane::Gpiv ( ) 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

Copy assignment operator.

Definition at line 51 of file plane.h.

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

Friends And Related Function Documentation

◆ apeq

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

Definition at line 61 of file plane.cpp.

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

◆ operator!=

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

Definition at line 58 of file plane.h.

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

◆ operator<<

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

Definition at line 158 of file plane.cpp.

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

◆ operator==

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

Definition at line 50 of file plane.cpp.

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

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: