Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Attributes | Friends | List of all members
JGEOMETRY3D::JAngle3D Class Reference

Data structure for angles in three dimensions. More...

#include <JAngle3D.hh>

Inheritance diagram for JGEOMETRY3D::JAngle3D:
JMATH::JMath< JAngle3D >

Public Member Functions

 JAngle3D ()
 Default constructor. More...
 
 JAngle3D (const double theta, const double phi)
 Constructor. More...
 
 JAngle3D (const double x, const double y, const double z)
 Constructor. More...
 
double getTheta () const
 Get theta angle. More...
 
double getPhi () const
 Get phi angle. More...
 
double getDX () const
 Get x direction. More...
 
double getDY () const
 Get y direction. More...
 
double getDZ () const
 Get z direction. More...
 
JAngle3Dnegate ()
 Negate angle. More...
 
JAngle3Dadd (const JAngle3D &angle)
 Add angle. More...
 
JAngle3Dsub (const JAngle3D &angle)
 Subtract angle. More...
 
JAngle3Dmul (const double factor)
 Scale angle. More...
 
JAngle3Ddiv (const double factor)
 Scale angle. More...
 
bool equals (const JAngle3D &angle, const double precision=std::numeric_limits< double >::min()) const
 Check equality. More...
 
double getDot (const JAngle3D &angle) const
 Get dot product. More...
 
JAngle3Dnormalise ()
 Normalise angles. More...
 
JAngle3Dmul (const JNullType &object)
 Multiply with object. More...
 

Protected Attributes

double __theta
 
double __phi
 

Friends

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

Detailed Description

Data structure for angles in three dimensions.

This class serves as input to the rotation matrix JRotation3D.

Definition at line 31 of file JAngle3D.hh.

Constructor & Destructor Documentation

JGEOMETRY3D::JAngle3D::JAngle3D ( )
inline

Default constructor.

Definition at line 38 of file JAngle3D.hh.

38  :
39  __theta(0.0),
40  __phi (0.0)
41  {}
JGEOMETRY3D::JAngle3D::JAngle3D ( const double  theta,
const double  phi 
)
inline

Constructor.

Parameters
thetatheta angle [rad]
phiphi angle [rad]

Definition at line 50 of file JAngle3D.hh.

51  :
52  __theta(theta),
53  __phi (phi)
54  {}
JGEOMETRY3D::JAngle3D::JAngle3D ( const double  x,
const double  y,
const double  z 
)
inline

Constructor.

Parameters
xx value
yy value
zz value

Definition at line 64 of file JAngle3D.hh.

66  :
67  __theta(0.0),
68  __phi (0.0)
69  {
70  const double v = x*x + y*y + z*z;
71 
72  if (v != 0.0) {
73  __theta = acos (z / sqrt(v));
74  __phi = atan2(y, x);
75  }
76  }
data_type v[N+1][M+1]
Definition: JPolint.hh:707

Member Function Documentation

double JGEOMETRY3D::JAngle3D::getTheta ( ) const
inline

Get theta angle.

Returns
theta angle

Definition at line 84 of file JAngle3D.hh.

85  {
86  return __theta;
87  }
double JGEOMETRY3D::JAngle3D::getPhi ( ) const
inline

Get phi angle.

Returns
phi angle

Definition at line 95 of file JAngle3D.hh.

96  {
97  return __phi;
98  }
double JGEOMETRY3D::JAngle3D::getDX ( ) const
inline

Get x direction.

Returns
x direction

Definition at line 106 of file JAngle3D.hh.

107  {
108  return sin(__theta) * cos(__phi);
109  }
double JGEOMETRY3D::JAngle3D::getDY ( ) const
inline

Get y direction.

Returns
y direction

Definition at line 117 of file JAngle3D.hh.

118  {
119  return sin(__theta) * sin(__phi);
120  }
double JGEOMETRY3D::JAngle3D::getDZ ( ) const
inline

Get z direction.

Returns
z direction

Definition at line 128 of file JAngle3D.hh.

129  {
130  return cos(__theta);
131  }
JAngle3D& JGEOMETRY3D::JAngle3D::negate ( )
inline

Negate angle.

Returns
this angle

Definition at line 139 of file JAngle3D.hh.

140  {
141  __theta = -__theta;
142  __phi = -__phi;
143 
144  return *this;
145  }
JAngle3D& JGEOMETRY3D::JAngle3D::add ( const JAngle3D angle)
inline

Add angle.

Parameters
angleangle
Returns
this angle

Definition at line 154 of file JAngle3D.hh.

155  {
156  __theta += angle.getTheta();
157  __phi += angle.getPhi();
158 
159  return *this;
160  }
double getPhi() const
Get phi angle.
Definition: JAngle3D.hh:95
double getTheta() const
Get theta angle.
Definition: JAngle3D.hh:84
JAngle3D& JGEOMETRY3D::JAngle3D::sub ( const JAngle3D angle)
inline

Subtract angle.

Parameters
angleangle
Returns
this angle

Definition at line 169 of file JAngle3D.hh.

170  {
171  __theta -= angle.getTheta();
172  __phi -= angle.getPhi();
173 
174  return *this;
175  }
double getPhi() const
Get phi angle.
Definition: JAngle3D.hh:95
double getTheta() const
Get theta angle.
Definition: JAngle3D.hh:84
JAngle3D& JGEOMETRY3D::JAngle3D::mul ( const double  factor)
inline

Scale angle.

Parameters
factormultiplication factor
Returns
this angle

Definition at line 183 of file JAngle3D.hh.

184  {
185  __theta *= factor;
186  __phi *= factor;
187 
188  return *this;
189  }
JAngle3D& JGEOMETRY3D::JAngle3D::div ( const double  factor)
inline

Scale angle.

Parameters
factordivision factor
Returns
this angle

Definition at line 198 of file JAngle3D.hh.

199  {
200  __theta /= factor;
201  __phi /= factor;
202 
203  return *this;
204  }
bool JGEOMETRY3D::JAngle3D::equals ( const JAngle3D 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 214 of file JAngle3D.hh.

216  {
217  return (fabs(getTheta() - angle.getTheta()) <= precision &&
218  fabs(getPhi() - angle.getPhi()) <= precision);
219  }
double getPhi() const
Get phi angle.
Definition: JAngle3D.hh:95
double getTheta() const
Get theta angle.
Definition: JAngle3D.hh:84
double JGEOMETRY3D::JAngle3D::getDot ( const JAngle3D angle) const
inline

Get dot product.

Parameters
angleangle
Returns
dot product

Definition at line 228 of file JAngle3D.hh.

229  {
230  return
231  cos(getTheta()) * cos(angle.getTheta()) +
232  sin(getTheta()) * sin(angle.getTheta()) *
233  cos(getPhi() - angle.getPhi());
234  }
double getPhi() const
Get phi angle.
Definition: JAngle3D.hh:95
double getTheta() const
Get theta angle.
Definition: JAngle3D.hh:84
JAngle3D& JGEOMETRY3D::JAngle3D::normalise ( )
inline

Normalise angles.

  • theta angle will be between 0 and π
  • phi angle will be between -π and +π
Returns
this angle

Definition at line 245 of file JAngle3D.hh.

246  {
247  using JTOOLS::PI;
248 
249  if (__theta > PI) { do { __theta -= PI; } while (__theta > PI); }
250  if (__theta < 0.0) { do { __theta += PI; } while (__theta < 0.0); }
251 
252  if (__phi > +PI) { do { __phi -= 2*PI; } while (__phi > +PI); }
253  if (__phi < -PI) { do { __phi += 2*PI; } while (__phi < -PI); }
254 
255  return *this;
256  }
static const double PI
Constants.
Definition: JConstants.hh:20
JAngle3D & JMATH::JMath< JAngle3D , 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,
JAngle3D angle 
)
friend

Write angle from input.

Parameters
ininput stream
angleangle
Returns
input stream

Definition at line 266 of file JAngle3D.hh.

267  {
268  in >> angle.__theta >> angle.__phi;
269 
270  return in;
271  }
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition: JSirene.sh:45
std::ostream& operator<< ( std::ostream &  out,
const JAngle3D angle 
)
friend

Write angle to output.

Parameters
outoutput stream
angleangle
Returns
output stream

Definition at line 281 of file JAngle3D.hh.

282  {
283  out << angle.getTheta() << ' ' << angle.getPhi();
284 
285  return out;
286  }
double getPhi() const
Get phi angle.
Definition: JAngle3D.hh:95
double getTheta() const
Get theta angle.
Definition: JAngle3D.hh:84
JReader& operator>> ( JReader in,
JAngle3D angle 
)
friend

Read angle from input.

Parameters
inreader
angleangle
Returns
reader

Definition at line 296 of file JAngle3D.hh.

297  {
298  in >> angle.__theta;
299  in >> angle.__phi;
300 
301  return in;
302  }
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition: JSirene.sh:45
JWriter& operator<< ( JWriter out,
const JAngle3D angle 
)
friend

Write angle to output.

Parameters
outwriter
angleangle
Returns
writer

Definition at line 312 of file JAngle3D.hh.

313  {
314  out << angle.getTheta();
315  out << angle.getPhi();
316 
317  return out;
318  }
double getPhi() const
Get phi angle.
Definition: JAngle3D.hh:95
double getTheta() const
Get theta angle.
Definition: JAngle3D.hh:84

Member Data Documentation

double JGEOMETRY3D::JAngle3D::__theta
protected

Definition at line 321 of file JAngle3D.hh.

double JGEOMETRY3D::JAngle3D::__phi
protected

Definition at line 322 of file JAngle3D.hh.


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