Jpp  18.0.1-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 | Friends | List of all members
JGEOMETRY2D::JPosition2D Class Reference

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

#include <JPosition2D.hh>

Inheritance diagram for JGEOMETRY2D::JPosition2D:
JGEOMETRY2D::JVector2D JMATH::JMath< JFirst_t, JSecond_t > JDETECTOR::JAnchor JGEOMETRY2D::JAxis2D JGEOMETRY2D::JCircle2D JGEOMETRY3D::JCylinder3D

Public Member Functions

 JPosition2D ()
 Default constructor. More...
 
 JPosition2D (const JVector2D &pos)
 Constructor. More...
 
 JPosition2D (const JAngle2D &angle)
 Constructor. More...
 
 JPosition2D (const JVersor2D &dir)
 Constructor. More...
 
 JPosition2D (const double x, const double y)
 Constructor. More...
 
const JPosition2DgetPosition () const
 Get position. More...
 
JPosition2DgetPosition ()
 Get position. More...
 
void setPosition (const JVector2D &pos)
 Set position. More...
 
 operator JAngle2D () const
 Type conversion operator. More...
 
 operator JVersor2D () const
 Type conversion operator. More...
 
JPosition2Drotate (const JRotation2D &R)
 Rotate. More...
 
JPosition2Drotate_back (const JRotation2D &R)
 Rotate back. More...
 
double getDot (const JAngle2D &angle) const
 Get dot product. More...
 
double getDot (const JVersor2D &versor) const
 Get dot product. More...
 
double getPerpDot (const JAngle2D &angle) const
 Get perpendicular dot product. More...
 
double getPerpDot (const JVersor2D &dir) const
 Get perpendicular dot product. More...
 
double getX () const
 Get x position. More...
 
double getY () const
 Get y position. More...
 
JVector2Dnegate ()
 Negate vector. More...
 
JVector2Dadd (const JVector2D &vector)
 Add vector. More...
 
JVector2Dsub (const JVector2D &vector)
 Subtract vector. More...
 
JVector2Dmul (const double factor)
 Scale vector. More...
 
JFirst_t & mul (const JSecond_t &object)
 Multiply with object. More...
 
JVector2Ddiv (const double factor)
 Scale vector. More...
 
JVector2Dtransform (const JMatrix2D &T)
 Transform. More...
 
bool equals (const JVector2D &vector, const double precision=std::numeric_limits< double >::min()) const
 Check equality. More...
 
double getLengthSquared () const
 Get length squared. More...
 
double getLength () const
 Get length. More...
 
double getDistanceSquared (const JVector2D &point) const
 Get squared of distance to point. More...
 
double getDistance (const JVector2D &point) const
 Get distance to point. More...
 
double getDot (const JVector2D &point) const
 Get dot product. More...
 
double getPerpDot (const JVector2D &point) const
 Get perpendicular dot product. More...
 

Protected Attributes

double __x
 
double __y
 

Friends

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

Detailed Description

Data structure for position in two dimensions.

Definition at line 31 of file JPosition2D.hh.

Constructor & Destructor Documentation

JGEOMETRY2D::JPosition2D::JPosition2D ( )
inline

Default constructor.

Definition at line 44 of file JPosition2D.hh.

44  :
45  JVector2D()
46  {}
JVector2D()
Default constructor.
Definition: JVector2D.hh:39
JGEOMETRY2D::JPosition2D::JPosition2D ( const JVector2D pos)
inline

Constructor.

Parameters
posposition

Definition at line 54 of file JPosition2D.hh.

54  :
55  JVector2D(pos)
56  {}
JVector2D()
Default constructor.
Definition: JVector2D.hh:39
JGEOMETRY2D::JPosition2D::JPosition2D ( const JAngle2D angle)
inline

Constructor.

Parameters
angleangle

Definition at line 64 of file JPosition2D.hh.

64  :
65  JVector2D(angle.getDX(),
66  angle.getDY())
67  {}
double getDX() const
Get x direction.
Definition: JAngle2D.hh:83
JVector2D()
Default constructor.
Definition: JVector2D.hh:39
double getDY() const
Get y direction.
Definition: JAngle2D.hh:94
JGEOMETRY2D::JPosition2D::JPosition2D ( const JVersor2D dir)
inline

Constructor.

Parameters
dirdirection

Definition at line 75 of file JPosition2D.hh.

75  :
76  JVector2D(dir.getDX(),
77  dir.getDY())
78  {}
JVector2D()
Default constructor.
Definition: JVector2D.hh:39
double getDX() const
Get x direction.
Definition: JVersor2D.hh:53
double getDY() const
Get y direction.
Definition: JVersor2D.hh:64
JGEOMETRY2D::JPosition2D::JPosition2D ( const double  x,
const double  y 
)
inline

Constructor.

Parameters
xx value
yy value

Definition at line 87 of file JPosition2D.hh.

88  :
89  JVector2D(x,y)
90  {}
JVector2D()
Default constructor.
Definition: JVector2D.hh:39

Member Function Documentation

const JPosition2D& JGEOMETRY2D::JPosition2D::getPosition ( ) const
inline

Get position.

Returns
position

Definition at line 98 of file JPosition2D.hh.

99  {
100  return static_cast<const JPosition2D&>(*this);
101  }
Data structure for position in two dimensions.
Definition: JPosition2D.hh:31
JPosition2D& JGEOMETRY2D::JPosition2D::getPosition ( )
inline

Get position.

Returns
position

Definition at line 109 of file JPosition2D.hh.

110  {
111  return static_cast<JPosition2D&>(*this);
112  }
Data structure for position in two dimensions.
Definition: JPosition2D.hh:31
void JGEOMETRY2D::JPosition2D::setPosition ( const JVector2D pos)
inline

Set position.

Parameters
posposition

Definition at line 120 of file JPosition2D.hh.

121  {
122  static_cast<JVector2D&>(*this) = pos;
123  }
Data structure for vector in two dimensions.
Definition: JVector2D.hh:32
JGEOMETRY2D::JPosition2D::operator JAngle2D ( ) const
inline

Type conversion operator.

Returns
angle

Definition at line 131 of file JPosition2D.hh.

132  {
133  return JAngle2D(getX(), getY());
134  }
Data structure for angle in two dimensions.
Definition: JAngle2D.hh:33
double getY() const
Get y position.
Definition: JVector2D.hh:74
double getX() const
Get x position.
Definition: JVector2D.hh:63
JGEOMETRY2D::JPosition2D::operator JVersor2D ( ) const
inline

Type conversion operator.

Returns
direction

Definition at line 142 of file JPosition2D.hh.

143  {
144  return JVersor2D(getX(), getY());
145  }
double getY() const
Get y position.
Definition: JVector2D.hh:74
Data structure for normalised vector in two dimensions.
Definition: JVersor2D.hh:20
double getX() const
Get x position.
Definition: JVector2D.hh:63
JPosition2D& JGEOMETRY2D::JPosition2D::rotate ( const JRotation2D R)
inline

Rotate.

Parameters
Rrotation matrix
Returns
this position

Definition at line 154 of file JPosition2D.hh.

155  {
156  R.rotate(__x, __y);
157 
158  return *this;
159  }
void rotate(double &__x, double &__y) const
Rotate.
Definition: JRotation2D.hh:96
JPosition2D& JGEOMETRY2D::JPosition2D::rotate_back ( const JRotation2D R)
inline

Rotate back.

Parameters
Rrotation matrix
Returns
this position

Definition at line 168 of file JPosition2D.hh.

169  {
170  R.rotate_back(__x, __y);
171 
172  return *this;
173  }
void rotate_back(double &__x, double &__y) const
Rotate back.
Definition: JRotation2D.hh:112
double JGEOMETRY2D::JPosition2D::getDot ( const JAngle2D angle) const
inline

Get dot product.

Parameters
angleangle
Returns
dot product

Definition at line 182 of file JPosition2D.hh.

183  {
184  return
185  getX() * angle.getDX() +
186  getY() * angle.getDY();
187  }
double getDX() const
Get x direction.
Definition: JAngle2D.hh:83
double getY() const
Get y position.
Definition: JVector2D.hh:74
double getX() const
Get x position.
Definition: JVector2D.hh:63
double getDY() const
Get y direction.
Definition: JAngle2D.hh:94
double JGEOMETRY2D::JPosition2D::getDot ( const JVersor2D versor) const
inline

Get dot product.

Parameters
versorversor
Returns
dot product

Definition at line 196 of file JPosition2D.hh.

197  {
198  return
199  getX() * versor.getDX() +
200  getY() * versor.getDY();
201  }
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::JPosition2D::getPerpDot ( const JAngle2D angle) const
inline

Get perpendicular dot product.

Parameters
angleangle
Returns
perpendicular dot product

Definition at line 210 of file JPosition2D.hh.

211  {
212  return
213  getX() * angle.getDY() -
214  getY() * angle.getDX();
215  }
double getDX() const
Get x direction.
Definition: JAngle2D.hh:83
double getY() const
Get y position.
Definition: JVector2D.hh:74
double getX() const
Get x position.
Definition: JVector2D.hh:63
double getDY() const
Get y direction.
Definition: JAngle2D.hh:94
double JGEOMETRY2D::JPosition2D::getPerpDot ( const JVersor2D dir) const
inline

Get perpendicular dot product.

Parameters
dirdirection
Returns
perpendicular dot product

Definition at line 224 of file JPosition2D.hh.

225  {
226  return
227  getX() * dir.getDY() -
228  getY() * dir.getDX();
229  }
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::JVector2D::getX ( ) const
inlineinherited

Get x position.

Returns
x position

Definition at line 63 of file JVector2D.hh.

64  {
65  return __x;
66  }
double JGEOMETRY2D::JVector2D::getY ( ) const
inlineinherited

Get y position.

Returns
y position

Definition at line 74 of file JVector2D.hh.

75  {
76  return __y;
77  }
JVector2D& JGEOMETRY2D::JVector2D::negate ( )
inlineinherited

Negate vector.

Returns
this vector

Definition at line 85 of file JVector2D.hh.

86  {
87  __x = -__x;
88  __y = -__y;
89 
90  return *this;
91  }
JVector2D& JGEOMETRY2D::JVector2D::add ( const JVector2D vector)
inlineinherited

Add vector.

Parameters
vectorvector
Returns
this vector

Definition at line 100 of file JVector2D.hh.

101  {
102  __x += vector.getX();
103  __y += vector.getY();
104 
105  return *this;
106  }
double getY() const
Get y position.
Definition: JVector2D.hh:74
double getX() const
Get x position.
Definition: JVector2D.hh:63
JVector2D& JGEOMETRY2D::JVector2D::sub ( const JVector2D vector)
inlineinherited

Subtract vector.

Parameters
vectorvector
Returns
this vector

Definition at line 115 of file JVector2D.hh.

116  {
117  __x -= vector.getX();
118  __y -= vector.getY();
119 
120  return *this;
121  }
double getY() const
Get y position.
Definition: JVector2D.hh:74
double getX() const
Get x position.
Definition: JVector2D.hh:63
JVector2D& JGEOMETRY2D::JVector2D::mul ( const double  factor)
inlineinherited

Scale vector.

Parameters
factormultiplication factor
Returns
this vector

Definition at line 130 of file JVector2D.hh.

131  {
132  __x *= factor;
133  __y *= factor;
134 
135  return *this;
136  }
template<class JFirst_t, class JSecond_t = JNullType>
JFirst_t& JMATH::JMath< JFirst_t, JSecond_t >::mul ( const JSecond_t &  object)
inlineinherited

Multiply with object.

Parameters
objectobject
Returns
result object

Definition at line 354 of file JMath.hh.

355  {
356  return static_cast<JFirst_t&>(*this) = JFirst_t().mul(static_cast<const JFirst_t&>(*this), object);
357  }
JVector2D& JGEOMETRY2D::JVector2D::div ( const double  factor)
inlineinherited

Scale vector.

Parameters
factordivision factor
Returns
this vector

Definition at line 145 of file JVector2D.hh.

146  {
147  __x /= factor;
148  __y /= factor;
149 
150  return *this;
151  }
JVector2D& JGEOMETRY2D::JVector2D::transform ( const JMatrix2D T)
inlineinherited

Transform.

Parameters
Tmatrix
Returns
this vector

Definition at line 160 of file JVector2D.hh.

161  {
162  T.transform(__x, __y);
163 
164  return *this;
165  }
do set_variable OUTPUT_DIRECTORY $WORKDIR T
bool JGEOMETRY2D::JVector2D::equals ( const JVector2D vector,
const double  precision = std::numeric_limits<double>::min() 
) const
inlineinherited

Check equality.

Parameters
vectorvector
precisionprecision
Returns
true if vectors are equal; else false

Definition at line 175 of file JVector2D.hh.

177  {
178  return (fabs(getX() - vector.getX()) <= precision &&
179  fabs(getY() - vector.getY()) <= precision);
180  }
double getY() const
Get y position.
Definition: JVector2D.hh:74
double getX() const
Get x position.
Definition: JVector2D.hh:63
double JGEOMETRY2D::JVector2D::getLengthSquared ( ) const
inlineinherited

Get length squared.

Returns
square of length

Definition at line 188 of file JVector2D.hh.

189  {
190  return getX()*getX() + getY()*getY();
191  }
double getY() const
Get y position.
Definition: JVector2D.hh:74
double getX() const
Get x position.
Definition: JVector2D.hh:63
double JGEOMETRY2D::JVector2D::getLength ( ) const
inlineinherited

Get length.

Returns
length

Definition at line 199 of file JVector2D.hh.

200  {
201  return sqrt(getLengthSquared());
202  }
double getLengthSquared() const
Get length squared.
Definition: JVector2D.hh:188
double JGEOMETRY2D::JVector2D::getDistanceSquared ( const JVector2D point) const
inlineinherited

Get squared of distance to point.

Parameters
pointpoint
Returns
square of distance

Definition at line 211 of file JVector2D.hh.

212  {
213  return JVector2D(point).sub(*this).getLengthSquared();
214  }
JVector2D()
Default constructor.
Definition: JVector2D.hh:39
double JGEOMETRY2D::JVector2D::getDistance ( const JVector2D point) const
inlineinherited

Get distance to point.

Parameters
pointpoint
Returns
distance

Definition at line 223 of file JVector2D.hh.

224  {
225  return sqrt(getDistanceSquared(point));
226  }
double getDistanceSquared(const JVector2D &point) const
Get squared of distance to point.
Definition: JVector2D.hh:211
double JGEOMETRY2D::JVector2D::getDot ( const JVector2D point) const
inlineinherited

Get dot product.

Parameters
pointvector
Returns
dot product

Definition at line 235 of file JVector2D.hh.

236  {
237  return
238  getX() * point.getX() +
239  getY() * point.getY();
240  }
double getY() const
Get y position.
Definition: JVector2D.hh:74
double getX() const
Get x position.
Definition: JVector2D.hh:63
double JGEOMETRY2D::JVector2D::getPerpDot ( const JVector2D point) const
inlineinherited

Get perpendicular dot product.

Parameters
pointvector
Returns
perpendicular dot product

Definition at line 249 of file JVector2D.hh.

250  {
251  return
252  getX() * point.getY() -
253  getY() * point.getX();
254  }
double getY() const
Get y position.
Definition: JVector2D.hh:74
double getX() const
Get x position.
Definition: JVector2D.hh:63

Friends And Related Function Documentation

std::istream& operator>> ( std::istream &  in,
JPosition2D position 
)
friend

Read position from input.

Parameters
ininput stream
positionposition
Returns
input stream

Definition at line 239 of file JPosition2D.hh.

240  {
241  in >> position.__x >> position.__y;
242 
243  return in;
244  }
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 JPosition2D position 
)
friend

Write position to output.

Parameters
outoutput stream
positionposition
Returns
output stream

Definition at line 254 of file JPosition2D.hh.

255  {
256  const JFormat format(out, getFormat<JPosition2D>(JFormat_t(9, 3, std::ios::fixed | std::ios::showpos)));
257 
258  out << format << position.getX() << ' '
259  << format << position.getY();
260 
261  return out;
262  }
double getY() const
Get y position.
Definition: JVector2D.hh:74
Auxiliary class to temporarily define format specifications.
Definition: JManip.hh:632
double getX() const
Get x position.
Definition: JVector2D.hh:63
Data structure for format specifications.
Definition: JManip.hh:522
JReader& operator>> ( JReader in,
JPosition2D position 
)
friend

Read position from input.

Parameters
inreader
positionposition
Returns
reader

Definition at line 272 of file JPosition2D.hh.

273  {
274  in >> position.__x;
275  in >> position.__y;
276 
277  return in;
278  }
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 JPosition2D position 
)
friend

Write position to output.

Parameters
outwriter
positionposition
Returns
writer

Definition at line 288 of file JPosition2D.hh.

289  {
290  out << position.__x;
291  out << position.__y;
292 
293  return out;
294  }

Member Data Documentation

double JGEOMETRY2D::JVector2D::__x
protectedinherited

Definition at line 257 of file JVector2D.hh.

double JGEOMETRY2D::JVector2D::__y
protectedinherited

Definition at line 258 of file JVector2D.hh.


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