Jpp  15.0.0-rc.2
the software that should make you happy
 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 double precision=std::numeric_limits< double >::min()) 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 20 of file JVersor2D.hh.

Constructor & Destructor Documentation

JGEOMETRY2D::JVersor2D::JVersor2D ( )
inline

Default constructor.

This constructor yields a unit y-vector.

Definition at line 27 of file JVersor2D.hh.

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

Constructor.

Parameters
dxdx value
dydy value

Definition at line 39 of file JVersor2D.hh.

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

Member Function Documentation

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

Get x direction.

Returns
x direction

Definition at line 53 of file JVersor2D.hh.

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

Get y direction.

Returns
y direction

Definition at line 64 of file JVersor2D.hh.

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

Get phi angle.

Returns
phi angle [rad]

Definition at line 75 of file JVersor2D.hh.

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

Negate versor.

Returns
this versor

Definition at line 86 of file JVersor2D.hh.

87  {
88  __dx = -__dx;
89  __dy = -__dy;
90 
91  return *this;
92  }
bool JGEOMETRY2D::JVersor2D::equals ( const JVersor2D versor,
const double  precision = std::numeric_limits<double>::min() 
) const
inline

Check equality.

Parameters
versorversor
precisionprecision
Returns
true if versors are equal; else false

Definition at line 102 of file JVersor2D.hh.

104  {
105  return (fabs(getDX() - versor.getDX()) <= precision &&
106  fabs(getDY() - versor.getDY()) <= precision);
107  }
double getDX() const
Get x direction.
Definition: JVersor2D.hh:53
double getDY() const
Get y direction.
Definition: JVersor2D.hh:64
double JGEOMETRY2D::JVersor2D::getDot ( const JVersor2D versor) const
inline

Get dot product.

Parameters
versorversor
Returns
dot product

Definition at line 116 of file JVersor2D.hh.

117  {
118  return
119  getDX() * versor.getDX() +
120  getDY() * versor.getDY();
121  }
double getDX() const
Get x direction.
Definition: JVersor2D.hh:53
double getDY() const
Get y direction.
Definition: JVersor2D.hh:64
double JGEOMETRY2D::JVersor2D::getPerpDot ( const JVersor2D versor) const
inline

Get perpendicular dot product.

Parameters
versorversor
Returns
perpendicular dot product

Definition at line 130 of file JVersor2D.hh.

131  {
132  return
133  getDX() * versor.getDY() -
134  getDY() * versor.getDX();
135  }
double getDX() const
Get x direction.
Definition: JVersor2D.hh:53
double getDY() const
Get y direction.
Definition: JVersor2D.hh:64
JVersor2D& JGEOMETRY2D::JVersor2D::normalise ( )
inline

Normalise versor.

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

Returns
this versor

Definition at line 144 of file JVersor2D.hh.

145  {
146  const double v = sqrt(getDX()*getDX() + getDY()*getDY());
147 
148  if (v != 0.0) {
149  __dx /= v;
150  __dy /= v;
151  } else {
152  __dx = 0.0;
153  __dy = 1.0;
154  }
155 
156  return *this;
157  }
double getDX() const
Get x direction.
Definition: JVersor2D.hh:53
double getDY() const
Get y direction.
Definition: JVersor2D.hh:64
data_type v[N+1][M+1]
Definition: JPolint.hh:740

Member Data Documentation

double JGEOMETRY2D::JVersor2D::__dx
protected

Definition at line 160 of file JVersor2D.hh.

double JGEOMETRY2D::JVersor2D::__dy
protected

Definition at line 161 of file JVersor2D.hh.


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