Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
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.
 
 JVersor2D (const double dx, const double dy)
 Constructor.
 
double getDX () const
 Get x direction.
 
double getDY () const
 Get y direction.
 
double getPhi () const
 Get phi angle.
 
JVersor2Dnegate ()
 Negate versor.
 
bool equals (const JVersor2D &versor, const double precision=std::numeric_limits< double >::min()) const
 Check equality.
 
double getDot (const JVersor2D &versor) const
 Get dot product.
 
double getPerpDot (const JVersor2D &versor) const
 Get perpendicular dot product.
 
JVersor2Dnormalise ()
 Normalise versor.
 

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

◆ JVersor2D() [1/2]

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

◆ JVersor2D() [2/2]

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

◆ getDX()

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 }

◆ getDY()

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 }

◆ getPhi()

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 }

◆ negate()

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 }

◆ equals()

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

◆ getDot()

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 }

◆ getPerpDot()

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 }

◆ normalise()

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 }

Member Data Documentation

◆ __dx

double JGEOMETRY2D::JVersor2D::__dx
protected

Definition at line 160 of file JVersor2D.hh.

◆ __dy

double JGEOMETRY2D::JVersor2D::__dy
protected

Definition at line 161 of file JVersor2D.hh.


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