diff options
| author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-07-26 16:18:40 -0400 | 
|---|---|---|
| committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-07-26 16:18:40 -0400 | 
| commit | 1160baa61bad605cf8a1d583e8ae356a54a942df (patch) | |
| tree | e7c865f38836a9a03349bbd803aae8be9b37a200 /lib/circle_group.h | |
| parent | 870555f569bc63fecdc7c0b16e72e4e002f21c13 (diff) | |
| download | c++-1160baa61bad605cf8a1d583e8ae356a54a942df.tar.gz c++-1160baa61bad605cf8a1d583e8ae356a54a942df.tar.bz2 c++-1160baa61bad605cf8a1d583e8ae356a54a942df.zip | |
many changes, including new spin spaces and groups and cleaning up core library code
Diffstat (limited to 'lib/circle_group.h')
| -rw-r--r-- | lib/circle_group.h | 46 | 
1 files changed, 46 insertions, 0 deletions
| diff --git a/lib/circle_group.h b/lib/circle_group.h new file mode 100644 index 0000000..cb7cadd --- /dev/null +++ b/lib/circle_group.h @@ -0,0 +1,46 @@ +#pragma once + +#include "angle.h" + +class circle_group_t { +  public: +    bool is_reflection; +    double x; + +    circle_group_t() : is_reflection(false), x(0) {} +    circle_group_t(bool x, double y) : is_reflection(x), x(y) {} + +    angle_t act(const angle_t& theta) const { +      if (is_reflection) { +        return angle_t(fmod(2 * M_PI + x - theta.x, 2 * M_PI)); +      } else { +        return angle_t(fmod(x + theta.x, 2 * M_PI)); +      } +    } + +    circle_group_t act(const circle_group_t& r) const { +      if (is_reflection) { +        return circle_group_t(!r.is_reflection, fmod(2 * M_PI + x - r.x, 2 * M_PI)); +      } else { +        return circle_group_t(r.is_reflection, fmod(x + r.x, 2 * M_PI)); +      } +    } + +    angle_t act_inverse(const angle_t& theta) const { +      if (is_reflection) { +        return act(theta); +      } else { +        return angle_t(fmod(2 * M_PI + theta.x - x, 2 * M_PI)); +      } +    } + +    circle_group_t act_inverse(const circle_group_t& r) const { +      if (is_reflection) { +        return act(r); +      } else { +        return circle_group_t(r.is_reflection, fmod(2 * M_PI + r.x - x, 2 * M_PI)); +      } +    } +}; + + | 
