#include <cmath>
#include <iostream>
#include <sstream>
#include "Rtypes.h"
Go to the source code of this file.
|
struct | Vec |
| The Vec class is a straightforward 3-d vector, which also works in pyroot. More...
|
|
◆ operator<<()
std::ostream & operator<< |
( |
std::ostream & | out, |
|
|
const Vec & | v ) |
|
inline |
Write vector to output stream.
- Parameters
-
- Returns
- output stream
Definition at line 284 of file Vec.hh.
285{
286 out << v.
x <<
" " << v.
y <<
" " << v.
z <<
" ";
287 return out;
288}
◆ operator>>()
std::istream & operator>> |
( |
std::istream & | in, |
|
|
Vec & | v ) |
|
inline |
Read vector from input stream.
- Parameters
-
- Returns
- input stream
Definition at line 297 of file Vec.hh.
298{
299 in >> v.
x >> v.
y >> v.
z ;
return in;
300}
◆ cos_angle_between()
double cos_angle_between |
( |
const Vec & | a, |
|
|
const Vec & | b ) |
|
inline |
Get cosine of space angle between two vectors.
- Parameters
-
a | first vector |
b | second vector |
- Returns
- cosine
Definition at line 309 of file Vec.hh.
310{
311 const double n =
a.len() * b.
len();
313}
double len() const
Get length.
◆ angle_between()
double angle_between |
( |
const Vec & | a, |
|
|
const Vec & | b ) |
|
inline |
Get space angle between two vectors.
- Parameters
-
a | first vector |
b | second vector |
- Returns
- angle [rad]
Definition at line 322 of file Vec.hh.
323{
325 if ( c < -1 ) return M_PI;
326 if ( c > 1 ) return 0;
327 return acos( c );
328}
double cos_angle_between(const Vec &a, const Vec &b)
Get cosine of space angle between two vectors.
◆ operator+()
Vec operator+ |
( |
const Vec & | a, |
|
|
const Vec & | b ) |
|
inline |
Add two vectors.
- Parameters
-
a | first vector |
b | second vector |
- Returns
- vector
Definition at line 337 of file Vec.hh.
337{
Vec r(a);
return r+=b;}
The Vec class is a straightforward 3-d vector, which also works in pyroot.
◆ operator-()
Vec operator- |
( |
const Vec & | a, |
|
|
const Vec & | b ) |
|
inline |
Subtract two vectors.
- Parameters
-
a | first vector |
b | second vector |
- Returns
- vector
Definition at line 346 of file Vec.hh.
346{
Vec r(a);
return r-=b;}
◆ operator*() [1/2]
Vec operator* |
( |
double | a, |
|
|
const Vec & | v ) |
|
inline |
Multiply vector.
- Parameters
-
- Returns
- vector
Definition at line 355 of file Vec.hh.
355{
return Vec(a*v.
x,a*v.
y,a*v.
z);}
◆ operator*() [2/2]
Vec operator* |
( |
const Vec & | v, |
|
|
double | a ) |
|
inline |
Multiply vector.
- Parameters
-
- Returns
- vector
Definition at line 364 of file Vec.hh.
364{
return Vec(a*v.
x,a*v.
y,a*v.
z);}
◆ operator/()
Vec operator/ |
( |
const Vec & | v, |
|
|
double | a ) |
|
inline |
Divide vector.
- Parameters
-
- Returns
- vector
Definition at line 373 of file Vec.hh.
373{
return Vec(v.
x/a,v.
y/a,v.
z/a);}