Geant4
9.6.p02
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
geant4_9_6_p02
source
externals
clhep
include
CLHEP
Geometry
Plane3D.h
Go to the documentation of this file.
1
// -*- C++ -*-
2
// $Id:$
3
// ---------------------------------------------------------------------------
4
//
5
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
6
//
7
// History:
8
// 22.09.96 E.Chernyaev - initial version
9
// 19.10.96 J.Allison - added == and <<.
10
// 15.04.03 E.Chernyaev - CLHEP-1.9: template version
11
12
#ifndef HEP_PLANE3D_H
13
#define HEP_PLANE3D_H
14
15
#include <iosfwd>
16
#include "
CLHEP/Geometry/Point3D.h
"
17
#include "
CLHEP/Geometry/Normal3D.h
"
18
#include "
CLHEP/Geometry/Transform3D.h
"
19
20
namespace
HepGeom {
21
28
template
<
class
T>
29
class
Plane3D
{
30
protected
:
31
T
a_
,
b_
,
c_
,
d_
;
32
33
public
:
36
Plane3D
() :
a_
(0.),
b_
(0.),
c_
(1.),
d_
(0.) {}
37
40
Plane3D
(T a1, T b1, T
c1
, T d1) :
a_
(a1),
b_
(b1),
c_
(c1),
d_
(d1) {}
41
44
Plane3D
(
const
Normal3D<T>
&
n
,
const
Point3D<T>
&
p
)
45
:
a_
(n.
x
()),
b_
(n.
y
()),
c_
(n.
z
()),
d_
(-n*p) {}
46
49
Plane3D
(
const
Point3D<T>
& p1,
50
const
Point3D<T>
& p2,
51
const
Point3D<T>
& p3) {
52
Normal3D<T>
n
= (p2-p1).cross(p3-p1);
53
a_
= n.
x
();
b_
= n.
y
();
c_
= n.
z
();
d_
= -n*p1;
54
}
55
62
Plane3D
(
const
Plane3D<float>
&
p
)
63
:
a_
(p.
a_
),
b_
(p.
b_
),
c_
(p.
c_
),
d_
(p.
d_
) {}
64
67
~Plane3D
() {};
68
71
Plane3D<T>
&
operator=
(
const
Plane3D<T>
&
p
) {
72
a_
= p.
a_
;
b_
= p.
b_
;
c_
= p.
c_
;
d_
= p.
d_
;
return
*
this
;
73
}
74
77
T
a
()
const
{
return
a_
; }
80
T
b
()
const
{
return
b_
; }
83
T
c
()
const
{
return
c_
; }
86
T
d
()
const
{
return
d_
; }
87
90
Normal3D<T>
normal
()
const
{
return
Normal3D<T>
(
a_
,
b_
,
c_
); }
91
94
Plane3D<T>
&
normalize
() {
95
double
ll = std::sqrt(
a_
*
a_
+
b_
*
b_
+
c_
*
c_
);
96
if
(ll > 0.) {
a_
/= ll;
b_
/= ll; c_ /= ll,
d_
/= ll; }
97
return
*
this
;
98
}
99
102
T
distance
(
const
Point3D<T>
&
p
)
const
{
103
return
a
()*p.
x
() +
b
()*p.
y
() +
c
()*p.
z
() +
d
();
104
}
105
108
Point3D<T>
point
(
const
Point3D<T>
&
p
)
const
{
109
T k =
distance
(p)/(
a
()*
a
()+
b
()*
b
()+
c
()*
c
());
110
return
Point3D<T>
(p.
x
()-
a
()*k, p.
y
()-
b
()*k, p.
z
()-
c
()*k);
111
}
112
115
Point3D<T>
point
()
const
{
116
T k = -
d
()/(
a
()*
a
()+
b
()*
b
()+
c
()*
c
());
117
return
Point3D<T>
(
a
()*k,
b
()*k,
c
()*k);
118
}
119
122
bool
operator ==
(
const
Plane3D<T>
&
p
)
const
{
123
return
a
() == p.
a
() &&
b
() == p.
b
() &&
c
() == p.
c
() &&
d
() == p.
d
();
124
}
125
128
bool
operator !=
(
const
Plane3D<T>
&
p
)
const
{
129
return
a
() != p.
a
() ||
b
() != p.
b
() ||
c
() != p.
c
() ||
d
() != p.
d
();
130
}
131
134
Plane3D<T>
&
transform
(
const
Transform3D
&
m
) {
135
Normal3D<T>
n
=
normal
();
136
n.transform(m);
137
d_
= -n*
point
().transform(m);
a_
= n.
x
();
b_
= n.
y
();
c_
= n.
z
();
138
return
*
this
;
139
}
140
};
141
146
std::ostream & operator<<(std::ostream & os, const Plane3D<float> &
p
);
147
152
std::ostream & operator<<(std::ostream & os, const Plane3D<double> &
p
);
153
154
}
/* namespace HepGeom */
155
156
#endif
/* HEP_PLANE3D_H */
Generated on Sat May 25 2013 14:33:05 for Geant4 by
1.8.4