summaryrefslogtreecommitdiff
path: root/lib/wolff_models/dihedral_inf.hpp
blob: 0b09c5954e9c141730469969bb08b9fd7bf9d4bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

#ifndef WOLFF_MODELS_DIHEDRAL_INF_H
#define WOLFF_MODELS_DIHEDRAL_INF_H

#include <cmath>
#include "height.hpp"

namespace wolff {

  template <class T>
  class dihedral_inf_t {
    public:
    bool is_reflection;
    T x;

    dihedral_inf_t() : is_reflection(false), x(0) {}
    dihedral_inf_t(bool x, T y) : is_reflection(x), x(y) {}

    height_t<T> act(const height_t<T>& h) const {
      if (this->is_reflection) {
        return height_t(this->x - h.x);
      } else {
        return height_t(this->x + h.x);
      }
    }

    dihedral_inf_t<T> act(const dihedral_inf_t<T>& r) const {
      if (this->is_reflection) {
        return dihedral_inf_t<T>(!r.is_reflection, this->x - r.x);
      } else {
        return dihedral_inf_t<T>(r.is_reflection, this->x + r.x);
      }
    }

    height_t<T> act_inverse(const height_t<T>& h) const {
      if (this->is_reflection) {
        return this->act(h);
      } else {
        return height_t(h.x - this->x);
      }
    }

    dihedral_inf_t<T> act_inverse(const dihedral_inf_t<T>& r) const {
      if (this->is_reflection) {
        return this->act(r);
      } else {
        return dihedral_inf_t<T>(r.is_reflection, r.x - this->x);
      }
    }
  };

}

#endif