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< JAngle2D >

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...
 
JAngle2Dmul (const JNullType &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 31 of file JAngle2D.hh.

Constructor & Destructor Documentation

JGEOMETRY2D::JAngle2D::JAngle2D ( )
inline

Default constructor.

Definition at line 38 of file JAngle2D.hh.

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

Constructor.

Parameters
phiphi angle [rad]

Definition at line 48 of file JAngle2D.hh.

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

Constructor.

Parameters
xx value
yy value

Definition at line 59 of file JAngle2D.hh.

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

Member Function Documentation

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

Get phi angle.

Returns
phi angle

Definition at line 70 of file JAngle2D.hh.

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

Get x direction.

Returns
x direction

Definition at line 81 of file JAngle2D.hh.

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

Get y direction.

Returns
y direction

Definition at line 92 of file JAngle2D.hh.

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

Negate angle.

Returns
this angle

Definition at line 103 of file JAngle2D.hh.

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

Add angle.

Parameters
angleangle
Returns
this angle

Definition at line 117 of file JAngle2D.hh.

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

Subtract angle.

Parameters
angleangle
Returns
this angle

Definition at line 131 of file JAngle2D.hh.

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

Scale angle.

Parameters
factormultiplication factor
Returns
this angle

Definition at line 145 of file JAngle2D.hh.

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

Scale angle.

Parameters
factordivision factor
Returns
this angle

Definition at line 159 of file JAngle2D.hh.

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

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

Get dot product.

Parameters
angleangle
Returns
dot product

Definition at line 187 of file JAngle2D.hh.

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

Normalise angle.

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

Definition at line 200 of file JAngle2D.hh.

201  {
202  using JTOOLS::PI;
203 
204  if (__phi > 2*PI) { do { __phi -= 2*PI; } while (__phi > 2*PI); }
205  if (__phi < 0.0) { do { __phi += 2*PI; } while (__phi < 0.0); }
206 
207  return *this;
208  }
static const double PI
Constants.
Definition: JConstants.hh:20
JAngle2D & JMATH::JMath< JAngle2D , JNullType >::mul ( const JNullType object)
inlineinherited

Multiply with object.

Parameters
objectobject
Returns
result object

Definition at line 273 of file JMath.hh.

274  {
275  return static_cast<JFirst_t&>(*this) = JCalculator<JFirst_t>::calculator.mul(static_cast<const JFirst_t&>(*this), object);
276  }
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 218 of file JAngle2D.hh.

219  {
220  return in >> angle.__phi;
221  }
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition: JSirene.sh:45
std::ostream& operator<< ( std::ostream &  out,
const JAngle2D angle 
)
friend

Write angle to output.

Parameters
outoutput stream
angleangle
Returns
output stream

Definition at line 231 of file JAngle2D.hh.

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

Read angle from input.

Parameters
inreader
angleangle
Returns
reader

Definition at line 244 of file JAngle2D.hh.

245  {
246  return in >> angle.__phi;
247  }
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition: JSirene.sh:45
JWriter& operator<< ( JWriter out,
const JAngle2D angle 
)
friend

Write angle to output.

Parameters
outwriter
angleangle
Returns
writer

Definition at line 257 of file JAngle2D.hh.

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

Member Data Documentation

double JGEOMETRY2D::JAngle2D::__phi
protected

Definition at line 263 of file JAngle2D.hh.


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