CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
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 Functions

(Note that these are not member functions.)

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 30 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 37 of file Plane3D.h.

37: 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 41 of file Plane3D.h.

41: 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 45 of file Plane3D.h.

46 : 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 50 of file Plane3D.h.

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

◆ 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 65 of file Plane3D.h.

66 : 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 86 of file Plane3D.h.

86{ return 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 89 of file Plane3D.h.

89{ return 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 92 of file Plane3D.h.

92{ return 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 95 of file Plane3D.h.

95{ return 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 111 of file Plane3D.h.

111 {
112 return a()*p.x() + b()*p.y() + c()*p.z() + d();
113 }
T d() const
Definition: Plane3D.h:95
T b() const
Definition: Plane3D.h:89
T c() const
Definition: Plane3D.h:92
T a() const
Definition: Plane3D.h:86

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

◆ normal()

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

Returns normal.

Definition at line 99 of file Plane3D.h.

99{ return Normal3D<T>(a_,b_,c_); }

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

◆ normalize()

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

Normalization.

Definition at line 103 of file Plane3D.h.

103 {
104 double ll = std::sqrt(a_*a_ + b_*b_ + c_*c_);
105 if (ll > 0.) { a_ /= ll; b_ /= ll; c_ /= ll, d_ /= ll; }
106 return *this;
107 }

◆ operator!=()

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

Test for inequality.

Definition at line 137 of file Plane3D.h.

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

◆ 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 131 of file Plane3D.h.

131 {
132 return a() == p.a() && b() == p.b() && c() == p.c() && d() == p.d();
133 }

◆ 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 124 of file Plane3D.h.

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

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 117 of file Plane3D.h.

117 {
118 T k = distance(p)/(a()*a()+b()*b()+c()*c());
119 return Point3D<T>(p.x()-a()*k, p.y()-b()*k, p.z()-c()*k);
120 }
T distance(const Point3D< T > &p) const
Definition: Plane3D.h:111

◆ transform()

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

Transformation by Transform3D.

Definition at line 143 of file Plane3D.h.

143 {
144 Normal3D<T> n = normal();
145 n.transform(m);
146 d_ = -n*point().transform(m); a_ = n.x(); b_ = n.y(); c_ = n.z();
147 return *this;
148 }
Normal3D< T > normal() const
Definition: Plane3D.h:99
Point3D< T > point() const
Definition: Plane3D.h:124

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 29 of file Plane3D.cc.

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

◆ operator<<() [2/2]

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

Output to the stream.

Definition at line 22 of file Plane3D.cc.

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

Member Data Documentation

◆ a_

◆ b_

◆ c_

◆ d_


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