summaryrefslogtreecommitdiffstats
path: root/dev/a4-dance/rotation_bounds.cc
blob: a83b1ced2686cf4751651fec90c404405a55f0ad (plain) (blame)
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
56
57
58
59
60
61
62
63
64
#include "rotation_bounds.h"
#include <cstdlib>

RotationBounds::RotationBounds() {
  dofRX = false;
  dofRY = false;
  dofRZ = false;
  minRX = 0;
  maxRX = 0;
  minRY = 0;
  maxRY = 0;
  minRZ = 0;
  maxRZ = 0;
  dofs = 0;
}

void RotationBounds::setdof(bool rx, bool ry, bool rz) {
  dofRX = rx;
  dofRY = ry;
  dofRZ = rz;
  dofs = rx + ry + rz;
}

void RotationBounds::setR(int index, float min, float max) {
  if (index > dofs) {
    std::abort(); // Trying to set past the max index.
  }
  if (index == 0) {
    if (dofRX) {
      minRX = min;
      maxRX = max;
    } else if (dofRY) {
      minRY = min;
      maxRY = max;
    } else if (dofRZ) {
      minRZ = min;
      maxRZ = max;
    } else {
      abort();
    }
  } else if (index == 1) {
    if (dofRX && dofRY) {
      minRY = min;
      maxRY = max;
    } else if (dofRX && dofRZ) {
      minRZ = min;
      maxRZ = max;
    } else if (dofRY && dofRZ) {
      minRZ = min;
      maxRZ = max;
    } else {
      abort();
    }
  } else if (index == 2) {
    if (dofRX && dofRY && dofRZ) {
      minRZ = min;
      maxRZ = max;
    } else {
      abort();
    }
  } else {
    abort();
  }
}