Geant4-11
Public Member Functions | Protected Attributes | Related Functions
HepGeom::Plane3D< T > Class Template Reference

#include <Plane3D.h>

Public Member Functions

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

Protected Attributes

a_
 
b_
 
c_
 
d_
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &os, const Plane3D< double > &p)
 
std::ostream & operator<< (std::ostream &os, const Plane3D< float > &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 ( a1,
b1,
c1,
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) {}
static const G4double 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 }

References HepGeom::Plane3D< T >::a_, HepGeom::Plane3D< T >::b_, HepGeom::Plane3D< T >::c_, HepGeom::Plane3D< T >::d_, and CLHEP::detail::n.

◆ 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

Returns the a-coefficient in the plane equation: a*x+b*y+c*z+d=0.

Definition at line 84 of file Plane3D.h.

84{ return a_; }

References HepGeom::Plane3D< T >::a_.

Referenced by HepGeom::Plane3D< T >::distance(), HepGeom::Plane3D< T >::operator!=(), HepGeom::Plane3D< T >::operator<<(), HepGeom::Plane3D< T >::operator==(), and HepGeom::Plane3D< T >::point().

◆ b()

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

Returns the b-coefficient in the plane equation: a*x+b*y+c*z+d=0.

Definition at line 87 of file Plane3D.h.

87{ return b_; }

References HepGeom::Plane3D< T >::b_.

Referenced by HepGeom::Plane3D< T >::distance(), HepGeom::Plane3D< T >::operator!=(), HepGeom::Plane3D< T >::operator<<(), HepGeom::Plane3D< T >::operator==(), and HepGeom::Plane3D< T >::point().

◆ c()

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

Returns the c-coefficient in the plane equation: a*x+b*y+c*z+d=0.

Definition at line 90 of file Plane3D.h.

90{ return c_; }

References HepGeom::Plane3D< T >::c_.

Referenced by HepGeom::Plane3D< T >::distance(), HepGeom::Plane3D< T >::operator!=(), HepGeom::Plane3D< T >::operator<<(), HepGeom::Plane3D< T >::operator==(), and HepGeom::Plane3D< T >::point().

◆ d()

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

Returns the free member of the plane equation: a*x+b*y+c*z+d=0.

Definition at line 93 of file Plane3D.h.

93{ return d_; }

References HepGeom::Plane3D< T >::d_.

Referenced by HepGeom::Plane3D< T >::distance(), HepGeom::Plane3D< T >::operator!=(), HepGeom::Plane3D< T >::operator<<(), HepGeom::Plane3D< T >::operator==(), and HepGeom::Plane3D< T >::point().

◆ 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

References HepGeom::Plane3D< T >::a(), HepGeom::Plane3D< T >::b(), HepGeom::Plane3D< T >::c(), HepGeom::Plane3D< T >::d(), HepGeom::BasicVector3D< T >::x(), HepGeom::BasicVector3D< T >::y(), and HepGeom::BasicVector3D< T >::z().

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

◆ normal()

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

◆ 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 }

References HepGeom::Plane3D< T >::a_, HepGeom::Plane3D< T >::b_, HepGeom::Plane3D< T >::c_, and HepGeom::Plane3D< T >::d_.

◆ 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 }

References HepGeom::Plane3D< T >::a(), HepGeom::Plane3D< T >::b(), HepGeom::Plane3D< T >::c(), and HepGeom::Plane3D< T >::d().

◆ 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 }

References HepGeom::Plane3D< T >::a(), HepGeom::Plane3D< T >::b(), HepGeom::Plane3D< T >::c(), and HepGeom::Plane3D< T >::d().

◆ 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 }

References HepGeom::Plane3D< T >::a(), HepGeom::Plane3D< T >::b(), HepGeom::Plane3D< T >::c(), and HepGeom::Plane3D< T >::d().

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

References HepGeom::Plane3D< T >::a(), HepGeom::Plane3D< T >::b(), HepGeom::Plane3D< T >::c(), HepGeom::Plane3D< T >::distance(), HepGeom::BasicVector3D< T >::x(), HepGeom::BasicVector3D< T >::y(), and HepGeom::BasicVector3D< T >::z().

Referenced by G4ViewParameters::SceneModifyingCommands(), 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 }
static constexpr double m
Definition: G4SIunits.hh:109
Normal3D< T > normal() const
Definition: Plane3D.h:97
Point3D< T > point() const
Definition: Plane3D.h:122

References HepGeom::Plane3D< T >::a_, HepGeom::Plane3D< T >::b_, HepGeom::Plane3D< T >::c_, HepGeom::Plane3D< T >::d_, m, CLHEP::detail::n, HepGeom::Plane3D< T >::normal(), and HepGeom::Plane3D< T >::point().

Friends And Related Function 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 }

References HepGeom::Plane3D< T >::a(), HepGeom::Plane3D< T >::b(), HepGeom::Plane3D< T >::c(), and HepGeom::Plane3D< T >::d().

◆ 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 }

References HepGeom::Plane3D< T >::a(), HepGeom::Plane3D< T >::b(), HepGeom::Plane3D< T >::c(), and HepGeom::Plane3D< T >::d().

Field Documentation

◆ a_

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

◆ b_

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

◆ c_

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

◆ d_

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

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