Basis.h
1//-*-C++-*-
2/***************************************************************************
3 *
4 * Copyright (C) 2004 by Willem van Straten
5 * Licensed under the Academic Free License version 2.1
6 *
7 ***************************************************************************/
8
9// epsic/src/util/Basis.h
10
11#ifndef __Basis_H
12#define __Basis_H
13
14#include "Matrix.h"
15#include "Conventions.h"
16
18template<typename T>
19class Basis {
20
21public:
22
24 Basis () { set_basis (Signal::Linear); }
25
28
30 Signal::Basis get_basis () const { return basis; }
31
33 void set_basis (double orientation, double ellipticity);
34
36 double get_orientation () const { return orientation; }
37
39 double get_ellipticity () const { return ellipticity; }
40
42 Vector<3,T> get_basis_vector (unsigned iaxis) const { return into[iaxis]; }
43
45 template<typename U>
46 Vector<3,U> get_in (const Vector<3,U>& vect) const { return into * vect; }
47
49 template<typename U>
50 Vector<3,U> get_out (const Vector<3,U>& vect) const { return outof * vect; }
51
52protected:
53
56
58 double orientation;
59
61 double ellipticity;
62
64 Matrix<3, 3, T> into;
65
67 Matrix<3, 3, T> outof;
68};
69
72template<typename T>
73void Basis<T>::set_basis (double _orientation, double _ellipticity)
74{
75 orientation = _orientation;
76 ellipticity = _ellipticity;
77
78 double cos_2o = cos (2.0*orientation);
79 double sin_2o = sin (2.0*orientation);
80 double cos_2e = cos (2.0*ellipticity);
81 double sin_2e = sin (2.0*ellipticity);
82
83 into[0] = Vector<3,T> (cos_2o*cos_2e, sin_2o, -cos_2o*sin_2e);
84 into[1] = Vector<3,T> (-sin_2o*cos_2e, cos_2o, sin_2o*sin_2e);
85 into[2] = Vector<3,T> (sin_2e, 0, cos_2e);
86
87 basis = Signal::Elliptical;
88
89 outof = transpose (into);
90}
91
93template<typename T>
95{
96 basis = _basis;
97
98 switch (basis) {
99
100 case Signal::Linear:
101 into[0] = Vector<3,T>::basis (0); // hat q
102 into[1] = Vector<3,T>::basis (1); // hat u
103 into[2] = Vector<3,T>::basis (2); // hat v
104 orientation = 0;
105 ellipticity = 0;
106 break;
107
108 case Signal::Circular:
109 into[0] = Vector<3,T>::basis (1); // hat q
110 into[1] = Vector<3,T>::basis (2); // hat u
111 into[2] = Vector<3,T>::basis (0); // hat v
112 orientation = 0.25*M_PI;
113 ellipticity = 0.25*M_PI;
114 break;
115
116 default:
117 throw std::runtime_error ("Basis::set_basis unrecognized basis");
118
119 }
120
121 outof = transpose (into);
122}
123
124#endif
125
Vector< 3, U > get_out(const Vector< 3, U > &vect) const
Matrix< 3, 3, T > into
Definition Basis.h:64
Signal::Basis basis
Definition Basis.h:55
double ellipticity
Definition Basis.h:61
double get_orientation() const
void set_basis(Signal::Basis basis)
Definition Basis.h:94
double orientation
Definition Basis.h:58
Vector< 3, T > get_basis_vector(unsigned iaxis) const
Vector< 3, U > get_in(const Vector< 3, U > &vect) const
Signal::Basis get_basis() const
Matrix< 3, 3, T > outof
Definition Basis.h:67
double get_ellipticity() const
static const Vector basis(unsigned i)
Basis
The basis in which the electric field is represented.
Definition Conventions.h:19

Generated using doxygen 1.14.0