Garfield++ 5.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
plane.h
Go to the documentation of this file.
1#ifndef PLANE_H
2#define PLANE_H
3
4/* Copyright (c) 2000 Igor B. Smirnov
5
6The file can be used, copied, modified, and distributed
7according to the terms of GNU Lesser General Public License version 2.1
8as published by the Free Software Foundation,
9and provided that the above copyright notice, this permission notice,
10and notices about any modifications of the original text
11appear in all copies and in supporting documentation.
12The file is provided "as is" without express or implied warranty.
13*/
14
17
18namespace Heed {
19
20class polyline;
21
22/// Plane, defined by defined by a point and a vector normal to the plane.
23
24class plane : public absref {
25 protected:
26 /// Origin point, pivot.
28 /// Direction of normal, unit vector.
30
31 public:
32 point Gpiv() const { return piv; }
33 vec Gdir() const { return dir; }
34
35 protected:
36 virtual absref_transmit get_components() override;
37 static absref absref::* aref[2];
38
39 public:
40 plane() : piv(), dir() {}
41 plane(const point& fpiv, const vec& fdir) : piv(fpiv), dir(unit_vec(fdir)) {}
42 plane(const straight& sl, const point& pt);
43 plane(const straight& sl1, const straight& sl2, vfloat prec);
44 // Good if lines are crossed or if they are different not crossed parallel.
45 // Otherwise vecerror != 0
46 // Prec is used for crossing of lines.
47
48 /// Copy constructor.
49 plane(const plane& p) : piv(p.piv), dir(p.dir) {}
50 /// Copy assignment operator.
51 plane& operator=(const plane& fpl) {
52 piv = fpl.piv;
53 dir = fpl.dir;
54 return *this;
55 }
56
57 friend int operator==(const plane& pl1, const plane& pl2);
58 friend int operator!=(const plane& pl1, const plane& pl2) {
59 return pl1 == pl2 ? 0 : 1;
60 }
61 friend bool apeq(const plane& pl1, const plane& pl2, vfloat prec);
62
63 /// Return 1 if a point is in the plane (within precision prec).
64 int check_point_in(const point& fp, vfloat prec) const;
65
66 /// Figure out whether a straight line crosses the plane
67 /// and return the intersection point if it does.
68 /// vecerror = 2: line is parallel to the plane.
69 /// vecerror = 3: line is in the plane.
70 point cross(const straight& sl) const;
71 /// Determine the intersection with another plane.
72 /// vecerror = 2: planes are parallel.
73 /// vecerror = 3: planes are identical.
74 straight cross(const plane& sl) const;
75
76 int cross(const polyline& pll, point* crpt, int& qcrpt, polyline* crpll,
77 int& qcrpll, vfloat prec) const;
78
79 vfloat distance(const point& fpt) const;
80 friend std::ostream& operator<<(std::ostream& file, const plane& s);
81};
82
83std::ostream& operator<<(std::ostream& file, const plane& s);
84}
85
86#endif
Plane, defined by defined by a point and a vector normal to the plane.
Definition plane.h:24
plane & operator=(const plane &fpl)
Copy assignment operator.
Definition plane.h:51
plane(const plane &p)
Copy constructor.
Definition plane.h:49
point cross(const straight &sl) const
Definition plane.cpp:75
friend bool apeq(const plane &pl1, const plane &pl2, vfloat prec)
Definition plane.cpp:61
vec Gdir() const
Definition plane.h:33
static absref absref::* aref[2]
Definition plane.h:37
friend std::ostream & operator<<(std::ostream &file, const plane &s)
Definition plane.cpp:158
point piv
Origin point, pivot.
Definition plane.h:27
point Gpiv() const
Definition plane.h:32
friend int operator!=(const plane &pl1, const plane &pl2)
Definition plane.h:58
vec dir
Direction of normal, unit vector.
Definition plane.h:29
friend int operator==(const plane &pl1, const plane &pl2)
Definition plane.cpp:50
plane(const point &fpiv, const vec &fdir)
Definition plane.h:41
int check_point_in(const point &fp, vfloat prec) const
Return 1 if a point is in the plane (within precision prec).
Definition plane.cpp:68
vfloat distance(const point &fpt) const
Definition plane.cpp:151
virtual absref_transmit get_components() override
Definition plane.cpp:22
Point.
Definition vec.h:368
Polyline.
Definition polyline.h:23
Straight line, as combination of vector and point.
Definition straight.h:24
Definition BGMesh.cpp:6
std::ostream & operator<<(std::ostream &file, const BGMesh &bgm)
Definition BGMesh.cpp:37
double vfloat
Definition vfloat.h:16