Jpp  17.2.1-pre0
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::JAngle2D Class Reference

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

#include <JAngle2D.hh>

Inheritance diagram for JGEOMETRY2D::JAngle2D:
JMATH::JMath< JFirst_t, JSecond_t >

Public Member Functions

 JAngle2D ()
 Default constructor. More...
 
 JAngle2D (const double phi)
 Constructor. More...
 
 JAngle2D (const double x, const double y)
 Constructor. More...
 
double getPhi () const
 Get phi angle. More...
 
double getDX () const
 Get x direction. More...
 
double getDY () const
 Get y direction. More...
 
JAngle2Dnegate ()
 Negate angle. More...
 
JAngle2Dadd (const JAngle2D &angle)
 Add angle. More...
 
JAngle2Dsub (const JAngle2D &angle)
 Subtract angle. More...
 
JAngle2Dmul (const double factor)
 Scale angle. More...
 
JAngle2Ddiv (const double factor)
 Scale angle. More...
 
bool equals (const JAngle2D &angle, const double precision=std::numeric_limits< double >::min()) const
 Check equality. More...
 
double getDot (const JAngle2D &angle) const
 Get dot product. More...
 
JAngle2Dnormalise ()
 Normalise angle. More...
 
JFirst_t & mul (const JSecond_t &object)
 Multiply with object. More...
 

Protected Attributes

double __phi
 

Friends

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

Detailed Description

Data structure for angle in two dimensions.

This class serves as input to the rotation matrix JRotation2D.

Definition at line 33 of file JAngle2D.hh.

Constructor & Destructor Documentation

JGEOMETRY2D::JAngle2D::JAngle2D ( )
inline

Default constructor.

Definition at line 40 of file JAngle2D.hh.

40  :
41  __phi(0.0)
42  {}
JGEOMETRY2D::JAngle2D::JAngle2D ( const double  phi)
inline

Constructor.

Parameters
phiphi angle [rad]

Definition at line 50 of file JAngle2D.hh.

50  :
51  __phi(phi)
52  {}
JGEOMETRY2D::JAngle2D::JAngle2D ( const double  x,
const double  y 
)
inline

Constructor.

Parameters
xx value
yy value

Definition at line 61 of file JAngle2D.hh.

62  :
63  __phi(atan2(y,x))
64  {}

Member Function Documentation

double JGEOMETRY2D::JAngle2D::getPhi ( ) const
inline

Get phi angle.

Returns
phi angle

Definition at line 72 of file JAngle2D.hh.

73  {
74  return __phi;
75  }
double JGEOMETRY2D::JAngle2D::getDX ( ) const
inline

Get x direction.

Returns
x direction

Definition at line 83 of file JAngle2D.hh.

84  {
85  return cos(__phi);
86  }
double JGEOMETRY2D::JAngle2D::getDY ( ) const
inline

Get y direction.

Returns
y direction

Definition at line 94 of file JAngle2D.hh.

95  {
96  return sin(__phi);
97  }
then usage set_variable ACOUSTICS_WORKDIR $WORKDIR set_variable FORMULA sin([0]+6.28 *([1]+[2]*x)*x)" set_variable DY 1.0e-8 mkdir $WORKDIR for DETECTOR in $DETECTORS[*]
JAngle2D& JGEOMETRY2D::JAngle2D::negate ( )
inline

Negate angle.

Returns
this angle

Definition at line 105 of file JAngle2D.hh.

106  {
107  __phi = -__phi;
108 
109  return *this;
110  }
JAngle2D& JGEOMETRY2D::JAngle2D::add ( const JAngle2D angle)
inline

Add angle.

Parameters
angleangle
Returns
this angle

Definition at line 119 of file JAngle2D.hh.

120  {
121  __phi += angle.getPhi();
122 
123  return *this;
124  }
double getPhi() const
Get phi angle.
Definition: JAngle2D.hh:72
JAngle2D& JGEOMETRY2D::JAngle2D::sub ( const JAngle2D angle)
inline

Subtract angle.

Parameters
angleangle
Returns
this angle

Definition at line 133 of file JAngle2D.hh.

134  {
135  __phi -= angle.getPhi();
136 
137  return *this;
138  }
double getPhi() const
Get phi angle.
Definition: JAngle2D.hh:72
JAngle2D& JGEOMETRY2D::JAngle2D::mul ( const double  factor)
inline

Scale angle.

Parameters
factormultiplication factor
Returns
this angle

Definition at line 147 of file JAngle2D.hh.

148  {
149  __phi *= factor;
150 
151  return *this;
152  }
JAngle2D& JGEOMETRY2D::JAngle2D::div ( const double  factor)
inline

Scale angle.

Parameters
factordivision factor
Returns
this angle

Definition at line 161 of file JAngle2D.hh.

162  {
163  __phi /= factor;
164 
165  return *this;
166  }
bool JGEOMETRY2D::JAngle2D::equals ( const JAngle2D angle,
const double  precision = std::numeric_limits<double>::min() 
) const
inline

Check equality.

Parameters
angleangle
precisionprecision
Returns
true if angles are equal; else false

Definition at line 176 of file JAngle2D.hh.

178  {
179  return fabs(getPhi() - angle.getPhi()) <= precision;
180  }
double getPhi() const
Get phi angle.
Definition: JAngle2D.hh:72
double JGEOMETRY2D::JAngle2D::getDot ( const JAngle2D angle) const
inline

Get dot product.

Parameters
angleangle
Returns
dot product

Definition at line 189 of file JAngle2D.hh.

190  {
191  return cos(getPhi() - angle.getPhi());
192  }
double getPhi() const
Get phi angle.
Definition: JAngle2D.hh:72
JAngle2D& JGEOMETRY2D::JAngle2D::normalise ( )
inline

Normalise angle.

  • phi angle will be between 0 and 2π
Returns
this angle

Definition at line 202 of file JAngle2D.hh.

203  {
204  using JMATH::PI;
205 
206  if (__phi > 2*PI) { do { __phi -= 2*PI; } while (__phi > 2*PI); }
207  if (__phi < 0.0) { do { __phi += 2*PI; } while (__phi < 0.0); }
208 
209  return *this;
210  }
static const double PI
Mathematical constants.
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  }

Friends And Related Function Documentation

std::istream& operator>> ( std::istream &  in,
JAngle2D angle 
)
friend

Read angle from input.

Parameters
ininput stream
angleangle
Returns
input stream

Definition at line 220 of file JAngle2D.hh.

221  {
222  return in >> angle.__phi;
223  }
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 JAngle2D angle 
)
friend

Write angle to output.

Parameters
outoutput stream
angleangle
Returns
output stream

Definition at line 233 of file JAngle2D.hh.

234  {
235  const JFormat format(out, getFormat<JAngle2D>(JFormat_t(9, 5, std::ios::fixed | std::ios::showpos)));
236 
237  return out << format << angle.getPhi();
238  }
Auxiliary class to temporarily define format specifications.
Definition: JManip.hh:632
double getPhi() const
Get phi angle.
Definition: JAngle2D.hh:72
Data structure for format specifications.
Definition: JManip.hh:522
JReader& operator>> ( JReader in,
JAngle2D angle 
)
friend

Read angle from input.

Parameters
inreader
angleangle
Returns
reader

Definition at line 248 of file JAngle2D.hh.

249  {
250  return in >> angle.__phi;
251  }
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 JAngle2D angle 
)
friend

Write angle to output.

Parameters
outwriter
angleangle
Returns
writer

Definition at line 261 of file JAngle2D.hh.

262  {
263  return out << angle.__phi;
264  }

Member Data Documentation

double JGEOMETRY2D::JAngle2D::__phi
protected

Definition at line 267 of file JAngle2D.hh.


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