Jpp  18.2.0-rc.1
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
JGEOMETRY3D::JAngle3D Class Reference

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

#include <JAngle3D.hh>

Inheritance diagram for JGEOMETRY3D::JAngle3D:
JMATH::JMath< JFirst_t, JSecond_t >

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...
 
JFirst_t & mul (const JSecond_t &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 33 of file JAngle3D.hh.

Constructor & Destructor Documentation

JGEOMETRY3D::JAngle3D::JAngle3D ( )
inline

Default constructor.

Definition at line 40 of file JAngle3D.hh.

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

Constructor.

Parameters
thetatheta angle [rad]
phiphi angle [rad]

Definition at line 52 of file JAngle3D.hh.

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

Constructor.

Parameters
xx value
yy value
zz value

Definition at line 66 of file JAngle3D.hh.

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

Member Function Documentation

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

Get theta angle.

Returns
theta angle

Definition at line 86 of file JAngle3D.hh.

87  {
88  return __theta;
89  }
double JGEOMETRY3D::JAngle3D::getPhi ( ) const
inline

Get phi angle.

Returns
phi angle

Definition at line 97 of file JAngle3D.hh.

98  {
99  return __phi;
100  }
double JGEOMETRY3D::JAngle3D::getDX ( ) const
inline

Get x direction.

Returns
x direction

Definition at line 108 of file JAngle3D.hh.

109  {
110  return sin(__theta) * cos(__phi);
111  }
then usage set_variable ACOUSTICS_WORKDIR $WORKDIR set_variable FORMULA sin([0]+2 *$PI *([1]+[2]*x)*x)" set_variable DY 1.0e-8 mkdir $WORKDIR for DETECTOR in $DETECTORS[*]
double JGEOMETRY3D::JAngle3D::getDY ( ) const
inline

Get y direction.

Returns
y direction

Definition at line 119 of file JAngle3D.hh.

120  {
121  return sin(__theta) * sin(__phi);
122  }
then usage set_variable ACOUSTICS_WORKDIR $WORKDIR set_variable FORMULA sin([0]+2 *$PI *([1]+[2]*x)*x)" set_variable DY 1.0e-8 mkdir $WORKDIR for DETECTOR in $DETECTORS[*]
double JGEOMETRY3D::JAngle3D::getDZ ( ) const
inline

Get z direction.

Returns
z direction

Definition at line 130 of file JAngle3D.hh.

131  {
132  return cos(__theta);
133  }
JAngle3D& JGEOMETRY3D::JAngle3D::negate ( )
inline

Negate angle.

Returns
this angle

Definition at line 141 of file JAngle3D.hh.

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

Add angle.

Parameters
angleangle
Returns
this angle

Definition at line 156 of file JAngle3D.hh.

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

Subtract angle.

Parameters
angleangle
Returns
this angle

Definition at line 171 of file JAngle3D.hh.

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

Scale angle.

Parameters
factormultiplication factor
Returns
this angle

Definition at line 185 of file JAngle3D.hh.

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

Scale angle.

Parameters
factordivision factor
Returns
this angle

Definition at line 200 of file JAngle3D.hh.

201  {
202  __theta /= factor;
203  __phi /= factor;
204 
205  return *this;
206  }
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 216 of file JAngle3D.hh.

218  {
219  return (fabs(getTheta() - angle.getTheta()) <= precision &&
220  fabs(getPhi() - angle.getPhi()) <= precision);
221  }
double getPhi() const
Get phi angle.
Definition: JAngle3D.hh:97
double getTheta() const
Get theta angle.
Definition: JAngle3D.hh:86
double JGEOMETRY3D::JAngle3D::getDot ( const JAngle3D angle) const
inline

Get dot product.

Parameters
angleangle
Returns
dot product

Definition at line 230 of file JAngle3D.hh.

231  {
232  return
233  cos(getTheta()) * cos(angle.getTheta()) +
234  sin(getTheta()) * sin(angle.getTheta()) *
235  cos(getPhi() - angle.getPhi());
236  }
double getPhi() const
Get phi angle.
Definition: JAngle3D.hh:97
double getTheta() const
Get theta angle.
Definition: JAngle3D.hh:86
then usage set_variable ACOUSTICS_WORKDIR $WORKDIR set_variable FORMULA sin([0]+2 *$PI *([1]+[2]*x)*x)" set_variable DY 1.0e-8 mkdir $WORKDIR for DETECTOR in $DETECTORS[*]
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 247 of file JAngle3D.hh.

248  {
249  using JMATH::PI;
250 
251  if (__theta > PI) { do { __theta -= PI; } while (__theta > PI); }
252  if (__theta < 0.0) { do { __theta += PI; } while (__theta < 0.0); }
253 
254  if (__phi > +PI) { do { __phi -= 2*PI; } while (__phi > +PI); }
255  if (__phi < -PI) { do { __phi += 2*PI; } while (__phi < -PI); }
256 
257  return *this;
258  }
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,
JAngle3D angle 
)
friend

Write angle from input.

Parameters
ininput stream
angleangle
Returns
input stream

Definition at line 268 of file JAngle3D.hh.

269  {
270  in >> angle.__theta >> angle.__phi;
271 
272  return in;
273  }
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 JAngle3D angle 
)
friend

Write angle to output.

Parameters
outoutput stream
angleangle
Returns
output stream

Definition at line 283 of file JAngle3D.hh.

284  {
285  const JFormat format(out, getFormat<JAngle3D>(JFormat_t(9, 5, std::ios::fixed | std::ios::showpos)));
286 
287  out << format << angle.getTheta() << ' '
288  << format << angle.getPhi();
289 
290  return out;
291  }
double getPhi() const
Get phi angle.
Definition: JAngle3D.hh:97
double getTheta() const
Get theta angle.
Definition: JAngle3D.hh:86
Auxiliary class to temporarily define format specifications.
Definition: JManip.hh:632
Data structure for format specifications.
Definition: JManip.hh:522
JReader& operator>> ( JReader in,
JAngle3D angle 
)
friend

Read angle from input.

Parameters
inreader
angleangle
Returns
reader

Definition at line 301 of file JAngle3D.hh.

302  {
303  in >> angle.__theta;
304  in >> angle.__phi;
305 
306  return in;
307  }
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 JAngle3D angle 
)
friend

Write angle to output.

Parameters
outwriter
angleangle
Returns
writer

Definition at line 317 of file JAngle3D.hh.

318  {
319  out << angle.__theta;
320  out << angle.__phi;
321 
322  return out;
323  }

Member Data Documentation

double JGEOMETRY3D::JAngle3D::__theta
protected

Definition at line 326 of file JAngle3D.hh.

double JGEOMETRY3D::JAngle3D::__phi
protected

Definition at line 327 of file JAngle3D.hh.


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