Jpp
 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 32 of file JAngle2D.hh.

Constructor & Destructor Documentation

JGEOMETRY2D::JAngle2D::JAngle2D ( )
inline

Default constructor.

Definition at line 39 of file JAngle2D.hh.

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

Constructor.

Parameters
phiphi angle [rad]

Definition at line 49 of file JAngle2D.hh.

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

Constructor.

Parameters
xx value
yy value

Definition at line 60 of file JAngle2D.hh.

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

Member Function Documentation

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

Get phi angle.

Returns
phi angle

Definition at line 71 of file JAngle2D.hh.

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

Get x direction.

Returns
x direction

Definition at line 82 of file JAngle2D.hh.

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

Get y direction.

Returns
y direction

Definition at line 93 of file JAngle2D.hh.

94  {
95  return sin(__phi);
96  }
JAngle2D& JGEOMETRY2D::JAngle2D::negate ( )
inline

Negate angle.

Returns
this angle

Definition at line 104 of file JAngle2D.hh.

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

Add angle.

Parameters
angleangle
Returns
this angle

Definition at line 118 of file JAngle2D.hh.

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

Subtract angle.

Parameters
angleangle
Returns
this angle

Definition at line 132 of file JAngle2D.hh.

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

Scale angle.

Parameters
factormultiplication factor
Returns
this angle

Definition at line 146 of file JAngle2D.hh.

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

Scale angle.

Parameters
factordivision factor
Returns
this angle

Definition at line 160 of file JAngle2D.hh.

161  {
162  __phi /= factor;
163 
164  return *this;
165  }
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 175 of file JAngle2D.hh.

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

Get dot product.

Parameters
angleangle
Returns
dot product

Definition at line 188 of file JAngle2D.hh.

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

Normalise angle.

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

Definition at line 201 of file JAngle2D.hh.

202  {
203  using JMATH::PI;
204 
205  if (__phi > 2*PI) { do { __phi -= 2*PI; } while (__phi > 2*PI); }
206  if (__phi < 0.0) { do { __phi += 2*PI; } while (__phi < 0.0); }
207 
208  return *this;
209  }
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 357 of file JMath.hh.

358  {
359  return static_cast<JFirst_t&>(*this) = JCalculator<JFirst_t>::calculator.mul(static_cast<const JFirst_t&>(*this), object);
360  }
Auxiliary class for arithmetic operations on objects.
Definition: JCalculator.hh:18

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 219 of file JAngle2D.hh.

220  {
221  return in >> angle.__phi;
222  }
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 typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:36
std::ostream& operator<< ( std::ostream &  out,
const JAngle2D angle 
)
friend

Write angle to output.

Parameters
outoutput stream
angleangle
Returns
output stream

Definition at line 232 of file JAngle2D.hh.

233  {
234  return out << angle.getPhi();
235  }
double getPhi() const
Get phi angle.
Definition: JAngle2D.hh:71
JReader& operator>> ( JReader in,
JAngle2D angle 
)
friend

Read angle from input.

Parameters
inreader
angleangle
Returns
reader

Definition at line 245 of file JAngle2D.hh.

246  {
247  return in >> angle.__phi;
248  }
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 typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:36
JWriter& operator<< ( JWriter out,
const JAngle2D angle 
)
friend

Write angle to output.

Parameters
outwriter
angleangle
Returns
writer

Definition at line 258 of file JAngle2D.hh.

259  {
260  return out << angle.__phi;
261  }

Member Data Documentation

double JGEOMETRY2D::JAngle2D::__phi
protected

Definition at line 264 of file JAngle2D.hh.


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