Jpp  17.1.0
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 31 of file JDirection2D.hh.

Constructor & Destructor Documentation

JGEOMETRY2D::JDirection2D::JDirection2D ( )
inline

Default constructor.

Definition at line 43 of file JDirection2D.hh.

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

Constructor.

Parameters
dirdirection

Definition at line 53 of file JDirection2D.hh.

53  :
54  JVersor2D(dir.getDY(), dir.getDX())
55  {}
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 63 of file JDirection2D.hh.

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

Constructor.

Parameters
posposition

Definition at line 73 of file JDirection2D.hh.

73  :
74  JVersor2D(pos.getY(),pos.getX())
75  {}
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 84 of file JDirection2D.hh.

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

Member Function Documentation

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

Get direction.

Returns
direction

Definition at line 95 of file JDirection2D.hh.

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

Get direction.

Returns
direction

Definition at line 106 of file JDirection2D.hh.

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

Set direction.

Parameters
dirdirection

Definition at line 117 of file JDirection2D.hh.

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

Type conversion operator.

Returns
angle

Definition at line 128 of file JDirection2D.hh.

129  {
130  return JAngle2D(getDX(), getDY());
131  }
Data structure for angle in two dimensions.
Definition: JAngle2D.hh:33
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 139 of file JDirection2D.hh.

140  {
141  return JVector2D(getDX(), getDY());
142  }
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 151 of file JDirection2D.hh.

152  {
153  T.transform(__dx, __dy);
154 
155  normalise();
156 
157  return *this;
158  }
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 167 of file JDirection2D.hh.

168  {
169  R.rotate(__dx, __dy);
170 
171  normalise();
172 
173  return *this;
174  }
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 183 of file JDirection2D.hh.

184  {
185  R.rotate_back(__dx, __dy);
186 
187  normalise();
188 
189  return *this;
190  }
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 199 of file JDirection2D.hh.

200  {
201  return
202  getDX() * angle.getDX() +
203  getDY() * angle.getDY();
204  }
double getDX() const
Get x direction.
Definition: JAngle2D.hh:83
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:94
double JGEOMETRY2D::JDirection2D::getDot ( const JVector2D pos) const
inline

Get dot product.

Parameters
posposition
Returns
dot product

Definition at line 213 of file JDirection2D.hh.

214  {
215  return
216  getDX() * pos.getX() +
217  getDY() * pos.getY();
218  }
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 227 of file JDirection2D.hh.

228  {
229  return
230  getDX() * angle.getDY() -
231  getDY() * angle.getDX();
232  }
double getDX() const
Get x direction.
Definition: JAngle2D.hh:83
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:94
double JGEOMETRY2D::JDirection2D::getPerpDot ( const JVector2D pos) const
inline

Get perpendicular dot product.

Parameters
posposition
Returns
perpendicular dot product

Definition at line 241 of file JDirection2D.hh.

242  {
243  return
244  getDX() * pos.getY() -
245  getDY() * pos.getX();
246  }
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:756

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 256 of file JDirection2D.hh.

257  {
258  in >> direction.__dx >> direction.__dy;
259 
260  return in;
261  }
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 JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
std::ostream& operator<< ( std::ostream &  out,
const JDirection2D direction 
)
friend

Write direction to output.

Parameters
outoutput stream
directiondirection
Returns
output stream

Definition at line 271 of file JDirection2D.hh.

272  {
273  const JFormat format(out, getFormat<JDirection2D>(JFormat_t(9, 6, std::ios::fixed | std::ios::showpos)));
274 
275  out << format << direction.getDX() << ' '
276  << format << direction.getDY();
277 
278  return out;
279  }
double getDX() const
Get x direction.
Definition: JVersor2D.hh:53
Auxiliary class to temporarily define format specifications.
Definition: JManip.hh:632
double getDY() const
Get y direction.
Definition: JVersor2D.hh:64
Data structure for format specifications.
Definition: JManip.hh:522
JReader& operator>> ( JReader in,
JDirection2D direction 
)
friend

Read direction from input.

Parameters
inreader
directiondirection
Returns
reader

Definition at line 289 of file JDirection2D.hh.

290  {
291  in >> direction.__dx;
292  in >> direction.__dy;
293 
294  return in;
295  }
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 JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
JWriter& operator<< ( JWriter out,
const JDirection2D direction 
)
friend

Write direction to output.

Parameters
outwriter
directiondirection
Returns
writer

Definition at line 305 of file JDirection2D.hh.

306  {
307  out << direction.__dx;
308  out << direction.__dy;
309 
310  return out;
311  }

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: