Jpp - the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Attributes | Friends | List of all members
JGEOMETRY2D::JDirection2D Class Reference

Data structure for direction in two dimensions. More...

#include <JDirection2D.hh>

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

Public Member Functions

 JDirection2D ()
 Default constructor. More...
 
 JDirection2D (const JVersor2D &dir)
 Constructor. More...
 
 JDirection2D (const JAngle2D &angle)
 Constructor. More...
 
 JDirection2D (const JVector2D &pos)
 Constructor. More...
 
 JDirection2D (const double dx, const double dy)
 Constructor. More...
 
const JDirection2DgetDirection () const
 Get direction. More...
 
JDirection2DgetDirection ()
 Get direction. More...
 
void setDirection (const JDirection2D &dir)
 Set direction. More...
 
 operator JAngle2D () const
 Type conversion operator. More...
 
 operator JVector2D () const
 Type conversion operator. More...
 
JDirection2Dtransform (const JMatrix2D &T)
 Transform. More...
 
JDirection2Drotate (const JRotation2D &R)
 Rotate. More...
 
JDirection2Drotate_back (const JRotation2D &R)
 Rotate back. More...
 
double getDot (const JAngle2D &angle) const
 Get dot product. More...
 
double getDot (const JVector2D &pos) const
 Get dot product. More...
 
double getPerpDot (const JAngle2D &angle) const
 Get perpendicular dot product. More...
 
double getPerpDot (const JVector2D &pos) const
 Get perpendicular dot product. 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
 

Friends

std::istream & operator>> (std::istream &in, JDirection2D &direction)
 Read direction from input. More...
 
std::ostream & operator<< (std::ostream &out, const JDirection2D &direction)
 Write direction to output. More...
 
JReaderoperator>> (JReader &in, JDirection2D &direction)
 Read direction from input. More...
 
JWriteroperator<< (JWriter &out, const JDirection2D &direction)
 Write direction to output. More...
 

Detailed Description

Data structure for direction in two dimensions.

Definition at line 30 of file JDirection2D.hh.

Constructor & Destructor Documentation

JGEOMETRY2D::JDirection2D::JDirection2D ( )
inline

Default constructor.

Definition at line 42 of file JDirection2D.hh.

42  :
43  JVersor2D()
44  {}
JVersor2D()
Default constructor.
Definition: JVersor2D.hh:27
JGEOMETRY2D::JDirection2D::JDirection2D ( const JVersor2D dir)
inline

Constructor.

Parameters
dirdirection

Definition at line 52 of file JDirection2D.hh.

52  :
53  JVersor2D(dir.getDY(), dir.getDX())
54  {}
double getDX() const
Get x direction.
Definition: JVersor2D.hh:53
JVersor2D()
Default constructor.
Definition: JVersor2D.hh:27
double getDY() const
Get y direction.
Definition: JVersor2D.hh:64
JGEOMETRY2D::JDirection2D::JDirection2D ( const JAngle2D angle)
inline

Constructor.

Parameters
angleangle

Definition at line 62 of file JDirection2D.hh.

62  :
63  JVersor2D(angle.getDX(), angle.getDY())
64  {}
double getDX() const
Get x direction.
Definition: JAngle2D.hh:82
JVersor2D()
Default constructor.
Definition: JVersor2D.hh:27
double getDY() const
Get y direction.
Definition: JAngle2D.hh:93
JGEOMETRY2D::JDirection2D::JDirection2D ( const JVector2D pos)
inline

Constructor.

Parameters
posposition

Definition at line 72 of file JDirection2D.hh.

72  :
73  JVersor2D(pos.getY(),pos.getX())
74  {}
double getY() const
Get y position.
Definition: JVector2D.hh:74
JVersor2D()
Default constructor.
Definition: JVersor2D.hh:27
double getX() const
Get x position.
Definition: JVector2D.hh:63
JGEOMETRY2D::JDirection2D::JDirection2D ( const double  dx,
const double  dy 
)
inline

Constructor.

Parameters
dxdx value
dydy value

Definition at line 83 of file JDirection2D.hh.

84  :
85  JVersor2D(dx, dy)
86  {}
JVersor2D()
Default constructor.
Definition: JVersor2D.hh:27

Member Function Documentation

const JDirection2D& JGEOMETRY2D::JDirection2D::getDirection ( ) const
inline

Get direction.

Returns
direction

Definition at line 94 of file JDirection2D.hh.

95  {
96  return static_cast<const JDirection2D&>(*this);
97  }
Data structure for direction in two dimensions.
Definition: JDirection2D.hh:30
JDirection2D& JGEOMETRY2D::JDirection2D::getDirection ( )
inline

Get direction.

Returns
direction

Definition at line 105 of file JDirection2D.hh.

106  {
107  return static_cast<JDirection2D&>(*this);
108  }
Data structure for direction in two dimensions.
Definition: JDirection2D.hh:30
void JGEOMETRY2D::JDirection2D::setDirection ( const JDirection2D dir)
inline

Set direction.

Parameters
dirdirection

Definition at line 116 of file JDirection2D.hh.

117  {
118  static_cast<JDirection2D&>(*this) = dir;
119  }
Data structure for direction in two dimensions.
Definition: JDirection2D.hh:30
JGEOMETRY2D::JDirection2D::operator JAngle2D ( ) const
inline

Type conversion operator.

Returns
angle

Definition at line 127 of file JDirection2D.hh.

128  {
129  return JAngle2D(getDX(), getDY());
130  }
Data structure for angle in two dimensions.
Definition: JAngle2D.hh:32
double getDX() const
Get x direction.
Definition: JVersor2D.hh:53
double getDY() const
Get y direction.
Definition: JVersor2D.hh:64
JGEOMETRY2D::JDirection2D::operator JVector2D ( ) const
inline

Type conversion operator.

Returns
position

Definition at line 138 of file JDirection2D.hh.

139  {
140  return JVector2D(getDX(), getDY());
141  }
Data structure for vector in two dimensions.
Definition: JVector2D.hh:32
double getDX() const
Get x direction.
Definition: JVersor2D.hh:53
double getDY() const
Get y direction.
Definition: JVersor2D.hh:64
JDirection2D& JGEOMETRY2D::JDirection2D::transform ( const JMatrix2D T)
inline

Transform.

Parameters
Tmatrix
Returns
this direction

Definition at line 150 of file JDirection2D.hh.

151  {
152  T.transform(__dx, __dy);
153 
154  normalise();
155 
156  return *this;
157  }
JVersor2D & normalise()
Normalise versor.
Definition: JVersor2D.hh:144
do set_variable OUTPUT_DIRECTORY $WORKDIR T
JDirection2D& JGEOMETRY2D::JDirection2D::rotate ( const JRotation2D R)
inline

Rotate.

Parameters
Rrotation matrix
Returns
this direction

Definition at line 166 of file JDirection2D.hh.

167  {
168  R.rotate(__dx, __dy);
169 
170  normalise();
171 
172  return *this;
173  }
void rotate(double &__x, double &__y) const
Rotate.
Definition: JRotation2D.hh:96
JVersor2D & normalise()
Normalise versor.
Definition: JVersor2D.hh:144
JDirection2D& JGEOMETRY2D::JDirection2D::rotate_back ( const JRotation2D R)
inline

Rotate back.

Parameters
Rrotation matrix
Returns
this direction

Definition at line 182 of file JDirection2D.hh.

183  {
184  R.rotate_back(__dx, __dy);
185 
186  normalise();
187 
188  return *this;
189  }
void rotate_back(double &__x, double &__y) const
Rotate back.
Definition: JRotation2D.hh:112
JVersor2D & normalise()
Normalise versor.
Definition: JVersor2D.hh:144
double JGEOMETRY2D::JDirection2D::getDot ( const JAngle2D angle) const
inline

Get dot product.

Parameters
angleangle
Returns
dot product

Definition at line 198 of file JDirection2D.hh.

199  {
200  return
201  getDX() * angle.getDX() +
202  getDY() * angle.getDY();
203  }
double getDX() const
Get x direction.
Definition: JAngle2D.hh:82
double getDX() const
Get x direction.
Definition: JVersor2D.hh:53
double getDY() const
Get y direction.
Definition: JVersor2D.hh:64
double getDY() const
Get y direction.
Definition: JAngle2D.hh:93
double JGEOMETRY2D::JDirection2D::getDot ( const JVector2D pos) const
inline

Get dot product.

Parameters
posposition
Returns
dot product

Definition at line 212 of file JDirection2D.hh.

213  {
214  return
215  getDX() * pos.getX() +
216  getDY() * pos.getY();
217  }
double getY() const
Get y position.
Definition: JVector2D.hh:74
double getDX() const
Get x direction.
Definition: JVersor2D.hh:53
double getX() const
Get x position.
Definition: JVector2D.hh:63
double getDY() const
Get y direction.
Definition: JVersor2D.hh:64
double JGEOMETRY2D::JDirection2D::getPerpDot ( const JAngle2D angle) const
inline

Get perpendicular dot product.

Parameters
angleangle
Returns
perpendicular dot product

Definition at line 226 of file JDirection2D.hh.

227  {
228  return
229  getDX() * angle.getDY() -
230  getDY() * angle.getDX();
231  }
double getDX() const
Get x direction.
Definition: JAngle2D.hh:82
double getDX() const
Get x direction.
Definition: JVersor2D.hh:53
double getDY() const
Get y direction.
Definition: JVersor2D.hh:64
double getDY() const
Get y direction.
Definition: JAngle2D.hh:93
double JGEOMETRY2D::JDirection2D::getPerpDot ( const JVector2D pos) const
inline

Get perpendicular dot product.

Parameters
posposition
Returns
perpendicular dot product

Definition at line 240 of file JDirection2D.hh.

241  {
242  return
243  getDX() * pos.getY() -
244  getDY() * pos.getX();
245  }
double getY() const
Get y position.
Definition: JVector2D.hh:74
double getDX() const
Get x direction.
Definition: JVersor2D.hh:53
double getX() const
Get x position.
Definition: JVector2D.hh:63
double getDY() const
Get y direction.
Definition: JVersor2D.hh:64
double JGEOMETRY2D::JVersor2D::getDX ( ) const
inlineinherited

Get x direction.

Returns
x direction

Definition at line 53 of file JVersor2D.hh.

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

Get y direction.

Returns
y direction

Definition at line 64 of file JVersor2D.hh.

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

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 ( )
inlineinherited

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
inlineinherited

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
inlineinherited

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
inlineinherited

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 ( )
inlineinherited

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

Friends And Related Function Documentation

std::istream& operator>> ( std::istream &  in,
JDirection2D direction 
)
friend

Read direction from input.

Parameters
ininput stream
directiondirection
Returns
input stream

Definition at line 255 of file JDirection2D.hh.

256  {
257  in >> direction.__dx >> direction.__dy;
258 
259  return in;
260  }
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:38
std::ostream& operator<< ( std::ostream &  out,
const JDirection2D direction 
)
friend

Write direction to output.

Parameters
outoutput stream
directiondirection
Returns
output stream

Definition at line 270 of file JDirection2D.hh.

271  {
272  out << direction.getDX() << ' ' << direction.getDY();
273 
274  return out;
275  }
double getDX() const
Get x direction.
Definition: JVersor2D.hh:53
double getDY() const
Get y direction.
Definition: JVersor2D.hh:64
JReader& operator>> ( JReader in,
JDirection2D direction 
)
friend

Read direction from input.

Parameters
inreader
directiondirection
Returns
reader

Definition at line 285 of file JDirection2D.hh.

286  {
287  in >> direction.__dx;
288  in >> direction.__dy;
289 
290  return in;
291  }
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:38
JWriter& operator<< ( JWriter out,
const JDirection2D direction 
)
friend

Write direction to output.

Parameters
outwriter
directiondirection
Returns
writer

Definition at line 301 of file JDirection2D.hh.

302  {
303  out << direction.getDX();
304  out << direction.getDY();
305 
306  return out;
307  }
double getDX() const
Get x direction.
Definition: JVersor2D.hh:53
double getDY() const
Get y direction.
Definition: JVersor2D.hh:64

Member Data Documentation

double JGEOMETRY2D::JVersor2D::__dx
protectedinherited

Definition at line 160 of file JVersor2D.hh.

double JGEOMETRY2D::JVersor2D::__dy
protectedinherited

Definition at line 161 of file JVersor2D.hh.


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