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

Constructor & Destructor Documentation

JGEOMETRY2D::JAngle2D::JAngle2D ( )
inline

Default constructor.

Definition at line 37 of file JAngle2D.hh.

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

Constructor.

Parameters
phiphi angle [rad]

Definition at line 47 of file JAngle2D.hh.

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

Constructor.

Parameters
xx value
yy value

Definition at line 58 of file JAngle2D.hh.

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

Member Function Documentation

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

Get phi angle.

Returns
phi angle

Definition at line 69 of file JAngle2D.hh.

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

Get x direction.

Returns
x direction

Definition at line 80 of file JAngle2D.hh.

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

Get y direction.

Returns
y direction

Definition at line 91 of file JAngle2D.hh.

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

Negate angle.

Returns
this angle

Definition at line 102 of file JAngle2D.hh.

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

Add angle.

Parameters
angleangle
Returns
this angle

Definition at line 116 of file JAngle2D.hh.

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

Subtract angle.

Parameters
angleangle
Returns
this angle

Definition at line 130 of file JAngle2D.hh.

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

Scale angle.

Parameters
factormultiplication factor
Returns
this angle

Definition at line 144 of file JAngle2D.hh.

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

Scale angle.

Parameters
factordivision factor
Returns
this angle

Definition at line 158 of file JAngle2D.hh.

159  {
160  __phi /= factor;
161 
162  return *this;
163  }
bool JGEOMETRY2D::JAngle2D::equals ( const JAngle2D angle) const
inline

Check equality.

Parameters
angleangle
Returns
true if angles are equal; else false

Definition at line 172 of file JAngle2D.hh.

173  {
174  return getPhi() == angle.getPhi();
175  }
double getPhi() const
Get phi angle.
Definition: JAngle2D.hh:69
double JGEOMETRY2D::JAngle2D::getDot ( const JAngle2D angle) const
inline

Get dot product.

Parameters
angleangle
Returns
dot product

Definition at line 184 of file JAngle2D.hh.

185  {
186  return cos(getPhi() - angle.getPhi());
187  }
double getPhi() const
Get phi angle.
Definition: JAngle2D.hh:69
JAngle2D& JGEOMETRY2D::JAngle2D::normalise ( )
inline

Normalise angle.

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

Definition at line 197 of file JAngle2D.hh.

198  {
199  using JTOOLS::PI;
200 
201  if (__phi > 2*PI) { do { __phi -= 2*PI; } while (__phi > 2*PI); }
202  if (__phi < 0.0) { do { __phi += 2*PI; } while (__phi < 0.0); }
203 
204  return *this;
205  }
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 product evaluation of 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 215 of file JAngle2D.hh.

216  {
217  return in >> angle.__phi;
218  }
std::ostream& operator<< ( std::ostream &  out,
const JAngle2D angle 
)
friend

Write angle to output.

Parameters
outoutput stream
angleangle
Returns
output stream

Definition at line 228 of file JAngle2D.hh.

229  {
230  return out << angle.getPhi();
231  }
double getPhi() const
Get phi angle.
Definition: JAngle2D.hh:69
JReader& operator>> ( JReader in,
JAngle2D angle 
)
friend

Read angle from input.

Parameters
inreader
angleangle
Returns
reader

Definition at line 241 of file JAngle2D.hh.

242  {
243  return in >> angle.__phi;
244  }
JWriter& operator<< ( JWriter out,
const JAngle2D angle 
)
friend

Write angle to output.

Parameters
outwriter
angleangle
Returns
writer

Definition at line 254 of file JAngle2D.hh.

255  {
256  return out << angle.__phi;
257  }

Member Data Documentation

double JGEOMETRY2D::JAngle2D::__phi
protected

Definition at line 260 of file JAngle2D.hh.


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