ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
Plane3D.h
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file Plane3D.h
1
// -*- C++ -*-
2
// ---------------------------------------------------------------------------
3
//
4
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
5
//
6
// History:
7
// 22.09.96 E.Chernyaev - initial version
8
// 19.10.96 J.Allison - added == and <<.
9
// 15.04.03 E.Chernyaev - CLHEP-1.9: template version
10
11
#ifndef HEP_PLANE3D_H
12
#define HEP_PLANE3D_H
13
14
#include <iosfwd>
15
#include "
CLHEP/Geometry/Point3D.h
"
16
#include "
CLHEP/Geometry/Normal3D.h
"
17
#include "
CLHEP/Geometry/Transform3D.h
"
18
19
namespace
HepGeom {
20
27
template
<
class
T>
28
class
Plane3D
{
29
protected
:
30
T
a_
,
b_
,
c_
,
d_
;
31
32
public
:
35
Plane3D
() :
a_
(0.),
b_
(0.),
c_
(1.),
d_
(0.) {}
36
39
Plane3D
(
T
a1,
T
b1,
T
c1
,
T
d1
) :
a_
(a1),
b_
(b1),
c_
(c1),
d_
(d1) {}
40
43
Plane3D
(
const
Normal3D<T>
&
n
,
const
Point3D<T>
&
p
)
44
:
a_
(n.
x
()),
b_
(n.
y
()),
c_
(n.
z
()),
d_
(-n*p) {}
45
48
Plane3D
(
const
Point3D<T>
& p1,
49
const
Point3D<T>
& p2,
50
const
Point3D<T>
& p3) {
51
Normal3D<T>
n
= (p2-p1).
cross
(p3-p1);
52
a_
= n.
x
();
b_
= n.
y
();
c_
= n.
z
();
d_
= -n*p1;
53
}
54
57
Plane3D
(
const
Plane3D<T>
&) =
default
;
58
61
template
<
typename
U =
T
,
62
typename
=
typename
std::enable_if<!std::is_same<U,float>::value
>::type>
63
Plane3D
(
const
Plane3D<float>
&
p
)
64
:
a_
(p.
a_
),
b_
(p.
b_
),
c_
(p.
c_
),
d_
(p.
d_
) {}
65
68
Plane3D
(
Plane3D<T>
&&) =
default
;
69
72
~Plane3D
() =
default
;
73
76
Plane3D<T>
&
operator=
(
const
Plane3D<T>
&) =
default
;
77
80
Plane3D<T>
&
operator=
(
Plane3D<T>
&&) =
default
;
81
84
T
a
()
const
{
return
a_
; }
87
T
b
()
const
{
return
b_
; }
90
T
c
()
const
{
return
c_
; }
93
T
d
()
const
{
return
d_
; }
94
97
Normal3D<T>
normal
()
const
{
return
Normal3D<T>
(
a_
,
b_
,
c_
); }
98
101
Plane3D<T>
&
normalize
() {
102
double
ll = std::sqrt(
a_
*
a_
+
b_
*
b_
+
c_
*
c_
);
103
if
(ll > 0.) {
a_
/= ll;
b_
/= ll; c_ /= ll,
d_
/= ll; }
104
return
*
this
;
105
}
106
109
T
distance
(
const
Point3D<T>
&
p
)
const
{
110
return
a
()*p.
x
() +
b
()*p.
y
() +
c
()*p.
z
() +
d
();
111
}
112
115
Point3D<T>
point
(
const
Point3D<T>
&
p
)
const
{
116
T
k
=
distance
(p)/(
a
()*
a
()+
b
()*
b
()+
c
()*
c
());
117
return
Point3D<T>
(p.
x
()-
a
()*
k
, p.
y
()-
b
()*
k
, p.
z
()-
c
()*
k
);
118
}
119
122
Point3D<T>
point
()
const
{
123
T
k
= -
d
()/(
a
()*
a
()+
b
()*
b
()+
c
()*
c
());
124
return
Point3D<T>
(
a
()*
k
,
b
()*
k
,
c
()*
k
);
125
}
126
129
bool
operator ==
(
const
Plane3D<T>
&
p
)
const
{
130
return
a
() == p.
a
() &&
b
() == p.
b
() &&
c
() == p.
c
() &&
d
() == p.
d
();
131
}
132
135
bool
operator !=
(
const
Plane3D<T>
&
p
)
const
{
136
return
a
() != p.
a
() ||
b
() != p.
b
() ||
c
() != p.
c
() ||
d
() != p.
d
();
137
}
138
141
Plane3D<T>
&
transform
(
const
Transform3D
&
m
) {
142
Normal3D<T>
n
=
normal
();
143
n.transform(m);
144
d_
= -n*
point
().transform(m);
a_
= n.
x
();
b_
= n.
y
();
c_
= n.
z
();
145
return
*
this
;
146
}
147
};
148
153
std::ostream & operator<<(std::ostream & os, const Plane3D<float> &
p
);
154
159
std::ostream & operator<<(std::ostream & os, const Plane3D<double> &
p
);
160
161
}
/* namespace HepGeom */
162
163
#endif
/* HEP_PLANE3D_H */
geant4
tree
geant4-10.6-release
source
externals
clhep
include
CLHEP
Geometry
Plane3D.h
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:14
using
1.8.2 with
ECCE GitHub integration