Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Attributes | List of all members
JGEOMETRY2D::JVersor2D Class Reference

Data structure for normalised vector in two dimensions. More...

#include <JVersor2D.hh>

Inheritance diagram for JGEOMETRY2D::JVersor2D:
JGEOMETRY2D::JDirection2D JGEOMETRY2D::JAxis2D

Public Member Functions

 JVersor2D ()
 Default constructor. More...
 
 JVersor2D (const double dx, const double dy)
 Constructor. More...
 
double getDX () const
 Get x direction. More...
 
double getDY () const
 Get y direction. More...
 
double getPhi () const
 Get phi angle. More...
 
JVersor2Dnegate ()
 Negate versor. More...
 
bool equals (const JVersor2D &versor) const
 Check equality. More...
 
double getDot (const JVersor2D &versor) const
 Get dot product. More...
 
double getPerpDot (const JVersor2D &versor) const
 Get perpendicular dot product. More...
 
JVersor2Dnormalise ()
 Normalise versor. More...
 

Protected Attributes

double __dx
 
double __dy
 

Detailed Description

Data structure for normalised vector in two dimensions.

Definition at line 19 of file JVersor2D.hh.

Constructor & Destructor Documentation

JGEOMETRY2D::JVersor2D::JVersor2D ( )
inline

Default constructor.

This constructor yields a unit y-vector.

Definition at line 26 of file JVersor2D.hh.

26  :
27  __dx(0.0),
28  __dy(1.0)
29  {}
JGEOMETRY2D::JVersor2D::JVersor2D ( const double  dx,
const double  dy 
)
inline

Constructor.

Parameters
dxdx value
dydy value

Definition at line 38 of file JVersor2D.hh.

39  :
40  __dx(dx),
41  __dy(dy)
42  {
43  normalise();
44  }
JVersor2D & normalise()
Normalise versor.
Definition: JVersor2D.hh:141

Member Function Documentation

double JGEOMETRY2D::JVersor2D::getDX ( ) const
inline

Get x direction.

Returns
x direction

Definition at line 52 of file JVersor2D.hh.

53  {
54  return __dx;
55  }
double JGEOMETRY2D::JVersor2D::getDY ( ) const
inline

Get y direction.

Returns
y direction

Definition at line 63 of file JVersor2D.hh.

64  {
65  return __dy;
66  }
double JGEOMETRY2D::JVersor2D::getPhi ( ) const
inline

Get phi angle.

Returns
phi angle [rad]

Definition at line 74 of file JVersor2D.hh.

75  {
76  return atan2(__dy, __dx);
77  }
JVersor2D& JGEOMETRY2D::JVersor2D::negate ( )
inline

Negate versor.

Returns
this versor

Definition at line 85 of file JVersor2D.hh.

86  {
87  __dx = -__dx;
88  __dy = -__dy;
89 
90  return *this;
91  }
bool JGEOMETRY2D::JVersor2D::equals ( const JVersor2D versor) const
inline

Check equality.

Parameters
versorversor
Returns
true if versors are equal; else false

Definition at line 100 of file JVersor2D.hh.

101  {
102  return (getDX() == versor.getDX() &&
103  getDY() == versor.getDY());
104  }
double getDX() const
Get x direction.
Definition: JVersor2D.hh:52
double getDY() const
Get y direction.
Definition: JVersor2D.hh:63
double JGEOMETRY2D::JVersor2D::getDot ( const JVersor2D versor) const
inline

Get dot product.

Parameters
versorversor
Returns
dot product

Definition at line 113 of file JVersor2D.hh.

114  {
115  return
116  getDX() * versor.getDX() +
117  getDY() * versor.getDY();
118  }
double getDX() const
Get x direction.
Definition: JVersor2D.hh:52
double getDY() const
Get y direction.
Definition: JVersor2D.hh:63
double JGEOMETRY2D::JVersor2D::getPerpDot ( const JVersor2D versor) const
inline

Get perpendicular dot product.

Parameters
versorversor
Returns
perpendicular dot product

Definition at line 127 of file JVersor2D.hh.

128  {
129  return
130  getDX() * versor.getDY() -
131  getDY() * versor.getDX();
132  }
double getDX() const
Get x direction.
Definition: JVersor2D.hh:52
double getDY() const
Get y direction.
Definition: JVersor2D.hh:63
JVersor2D& JGEOMETRY2D::JVersor2D::normalise ( )
inline

Normalise versor.

This operation may set the result to the unit y-vector.

Returns
this versor

Definition at line 141 of file JVersor2D.hh.

142  {
143  const double v = sqrt(getDX()*getDX() + getDY()*getDY());
144 
145  if (v != 0.0) {
146  __dx /= v;
147  __dy /= v;
148  } else {
149  __dx = 0.0;
150  __dy = 1.0;
151  }
152 
153  return *this;
154  }
double getDX() const
Get x direction.
Definition: JVersor2D.hh:52
double getDY() const
Get y direction.
Definition: JVersor2D.hh:63

Member Data Documentation

double JGEOMETRY2D::JVersor2D::__dx
protected

Definition at line 157 of file JVersor2D.hh.

double JGEOMETRY2D::JVersor2D::__dy
protected

Definition at line 158 of file JVersor2D.hh.


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