summaryrefslogtreecommitdiff
path: root/lib/angle.h
blob: c3f128ea02cf36f30e8e5ed4fc068215a36e765e (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
#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;
}