Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
HepGeom::Plane3D< T > Class Template Reference

#include <Plane3D.h>

Public Member Functions

 Plane3D ()
 
 Plane3D (T a1, T b1, T c1, T d1)
 
 Plane3D (const Normal3D< T > &n, const Point3D< T > &p)
 
 Plane3D (const Point3D< T > &p1, const Point3D< T > &p2, const Point3D< T > &p3)
 
 Plane3D (const Plane3D< T > &)=default
 
template<typename U = T, typename = typename std::enable_if<!std::is_same<U,float>::value >::type>
 Plane3D (const Plane3D< float > &p)
 
 Plane3D (Plane3D< T > &&)=default
 
 ~Plane3D ()=default
 
Plane3D< T > & operator= (const Plane3D< T > &)=default
 
Plane3D< T > & operator= (Plane3D< T > &&)=default
 
a () const
 
b () const
 
c () const
 
d () const
 
Normal3D< T > normal () const
 
Plane3D< T > & normalize ()
 
distance (const Point3D< T > &p) const
 
Point3D< T > point (const Point3D< T > &p) const
 
Point3D< T > point () const
 
bool operator== (const Plane3D< T > &p) const
 
bool operator!= (const Plane3D< T > &p) const
 
Plane3D< T > & transform (const Transform3D &m)
 

Protected Attributes

a_
 
b_
 
c_
 
d_
 

Related Symbols

(Note that these are not member symbols.)

std::ostream & operator<< (std::ostream &os, const Plane3D< float > &p)
 
std::ostream & operator<< (std::ostream &os, const Plane3D< double > &p)
 

Detailed Description

template<class T>
class HepGeom::Plane3D< T >

Template class for geometrical plane in 3D.

Author
Evgeni Chernyaev Evgue.nosp@m.ni.T.nosp@m.chern.nosp@m.iaev.nosp@m.@cern.nosp@m..ch

Definition at line 28 of file Plane3D.h.

Constructor & Destructor Documentation

◆ Plane3D() [1/7]

template<class T >
HepGeom::Plane3D< T >::Plane3D ( )
inline

Default constructor - creates plane z=0.

Definition at line 35 of file Plane3D.h.

35: a_(0.), b_(0.), c_(1.), d_(0.) {}

◆ Plane3D() [2/7]

template<class T >
HepGeom::Plane3D< T >::Plane3D ( T a1,
T b1,
T c1,
T d1 )
inline

Constructor from four numbers - creates plane a*x+b*y+c*z+d=0.

Definition at line 39 of file Plane3D.h.

39: a_(a1), b_(b1), c_(c1), d_(d1) {}

◆ Plane3D() [3/7]

template<class T >
HepGeom::Plane3D< T >::Plane3D ( const Normal3D< T > & n,
const Point3D< T > & p )
inline

Constructor from normal and point.

Definition at line 43 of file Plane3D.h.

44 : a_(n.x()), b_(n.y()), c_(n.z()), d_(-n*p) {}

◆ Plane3D() [4/7]

template<class T >
HepGeom::Plane3D< T >::Plane3D ( const Point3D< T > & p1,
const Point3D< T > & p2,
const Point3D< T > & p3 )
inline

Constructor from three points.

Definition at line 48 of file Plane3D.h.

50 {
51 Normal3D<T> n = (p2-p1).cross(p3-p1);
52 a_ = n.x(); b_ = n.y(); c_ = n.z(); d_ = -n*p1;
53 }

◆ Plane3D() [5/7]

template<class T >
HepGeom::Plane3D< T >::Plane3D ( const Plane3D< T > & )
default

Copy constructor.

◆ Plane3D() [6/7]

template<class T >
template<typename U = T, typename = typename std::enable_if<!std::is_same<U,float>::value >::type>
HepGeom::Plane3D< T >::Plane3D ( const Plane3D< float > & p)
inline

Constructor for Plane3D<double> from Plane3D<float>.

Definition at line 63 of file Plane3D.h.

64 : a_(p.a_), b_(p.b_), c_(p.c_), d_(p.d_) {}

◆ Plane3D() [7/7]

template<class T >
HepGeom::Plane3D< T >::Plane3D ( Plane3D< T > && )
default

Move constructor.

◆ ~Plane3D()

template<class T >
HepGeom::Plane3D< T >::~Plane3D ( )
default

Destructor.

Member Function Documentation

◆ a()

template<class T >
T HepGeom::Plane3D< T >::a ( ) const
inline

◆ b()

template<class T >
T HepGeom::Plane3D< T >::b ( ) const
inline

◆ c()

template<class T >
T HepGeom::Plane3D< T >::c ( ) const
inline

◆ d()

template<class T >
T HepGeom::Plane3D< T >::d ( ) const
inline

◆ distance()

template<class T >
T HepGeom::Plane3D< T >::distance ( const Point3D< T > & p) const
inline

Returns distance to the point.

Definition at line 109 of file Plane3D.h.

109 {
110 return a()*p.x() + b()*p.y() + c()*p.z() + d();
111 }
T d() const
Definition Plane3D.h:93
T b() const
Definition Plane3D.h:87
T c() const
Definition Plane3D.h:90
T a() const
Definition Plane3D.h:84

Referenced by HepGeom::Plane3D< T >::point().

◆ normal()

◆ normalize()

template<class T >
Plane3D< T > & HepGeom::Plane3D< T >::normalize ( )
inline

Normalization.

Definition at line 101 of file Plane3D.h.

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

◆ operator!=()

template<class T >
bool HepGeom::Plane3D< T >::operator!= ( const Plane3D< T > & p) const
inline

Test for inequality.

Definition at line 135 of file Plane3D.h.

135 {
136 return a() != p.a() || b() != p.b() || c() != p.c() || d() != p.d();
137 }

◆ operator=() [1/2]

template<class T >
Plane3D< T > & HepGeom::Plane3D< T >::operator= ( const Plane3D< T > & )
default

Assignment.

◆ operator=() [2/2]

template<class T >
Plane3D< T > & HepGeom::Plane3D< T >::operator= ( Plane3D< T > && )
default

Move assignment.

◆ operator==()

template<class T >
bool HepGeom::Plane3D< T >::operator== ( const Plane3D< T > & p) const
inline

Test for equality.

Definition at line 129 of file Plane3D.h.

129 {
130 return a() == p.a() && b() == p.b() && c() == p.c() && d() == p.d();
131 }

◆ point() [1/2]

template<class T >
Point3D< T > HepGeom::Plane3D< T >::point ( ) const
inline

Returns projection of the origin to the plane.

Definition at line 122 of file Plane3D.h.

122 {
123 T k = -d()/(a()*a()+b()*b()+c()*c());
124 return Point3D<T>(a()*k, b()*k, c()*k);
125 }

Referenced by HepGeom::Plane3D< T >::transform().

◆ point() [2/2]

template<class T >
Point3D< T > HepGeom::Plane3D< T >::point ( const Point3D< T > & p) const
inline

Returns projection of the point to the plane.

Definition at line 115 of file Plane3D.h.

115 {
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 }
T distance(const Point3D< T > &p) const
Definition Plane3D.h:109

Referenced by G4Plane3DToVtkPlane(), G4ViewParameters::SceneModifyingCommands(), G4VtkClipClosedSurfacePipeline::SetPlane(), G4VtkClipOpenPipeline::SetPlane(), G4VtkCutterPipeline::SetPlane(), and G4OpenGLQtViewer::updateViewerPropertiesTableWidget().

◆ transform()

template<class T >
Plane3D< T > & HepGeom::Plane3D< T >::transform ( const Transform3D & m)
inline

Transformation by Transform3D.

Definition at line 141 of file Plane3D.h.

141 {
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 }
Normal3D< T > normal() const
Definition Plane3D.h:97
Point3D< T > point() const
Definition Plane3D.h:122

Friends And Related Symbol Documentation

◆ operator<<() [1/2]

template<class T >
std::ostream & operator<< ( std::ostream & os,
const Plane3D< double > & p )
related

Output to the stream.

Definition at line 27 of file Plane3D.cc.

28 {
29 return os
30 << '(' << p.a() << ',' << p.b() << ',' << p.c() << ',' << p.d() << ')';
31 }

◆ operator<<() [2/2]

template<class T >
std::ostream & operator<< ( std::ostream & os,
const Plane3D< float > & p )
related

Output to the stream.

Definition at line 20 of file Plane3D.cc.

21 {
22 return os
23 << '(' << p.a() << ',' << p.b() << ',' << p.c() << ',' << p.d() << ')';
24 }

Member Data Documentation

◆ a_

◆ b_

◆ c_

◆ d_


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