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/angle.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/angle.h')
-rw-r--r-- | lib/angle.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/angle.h b/lib/angle.h new file mode 100644 index 0000000..c3f128e --- /dev/null +++ b/lib/angle.h @@ -0,0 +1,48 @@ +#pragma once + +#include "types.h" + +#include <cmath> +#include "vector.h" + +class angle_t { + public: + double x; + + typedef vector_t<2, double> M_t; + typedef vector_t<2, double> F_t; + + angle_t() : x(0) {} + angle_t(double x) : x(x) {} + + inline vector_t<2, double> operator*(v_t a) const { + vector_t<2, double>M; + M[0] = a * cos(x); + M[1] = a * sin(x); + + return M; + } + + inline vector_t<2, double> operator*(double a) const { + vector_t<2, double>M; + M[0] = a * cos(x); + M[1] = a * sin(x); + + return M; + } +}; + +inline vector_t<2,double>& operator+=(vector_t<2,double>& M, const angle_t& theta) { + M[0] += cos(theta.x); + M[1] += sin(theta.x); + + return M; +} + +inline vector_t<2,double>& operator-=(vector_t<2,double>& M, const angle_t& theta) { + M[0] -= cos(theta.x); + M[1] -= sin(theta.x); + + return M; +} + |