-
Notifications
You must be signed in to change notification settings - Fork 0
/
Target.cpp
102 lines (86 loc) · 2.14 KB
/
Target.cpp
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#include <string.h>
#include <stdio.h>
#include "target.h"
Target::Target(ID id) {
this->id = id;
SetHorizontalAngle(0.0);
}
Target::Target(ID id, float angle) {
this->id = id;
SetHorizontalAngle(angle);
}
Target::~Target() {
}
//
// Returns the target rim height in meters
//
float Target::GetRimHeight() {
switch (id) {
case Bottom : return 0.711;
case Left : return 1.559;
case Right : return 1.559;
case Middle : return 1.559;
case Top : return 2.489;
}
return 0.0;
}
//
// Returns the arc height in meters
//
float Target::GetArcHeight() {
switch (id) {
case Bottom : return GetRimHeight() + 1.0; // TODO - GUESSES! - tune this
case Left : return GetRimHeight() + 1.0; // TODO - GUESSES! - tune this
case Right : return GetRimHeight() + 1.0; // TODO - GUESSES! - tune this
case Middle : return GetRimHeight() + 1.0; // TODO - GUESSES! - tune this
case Top : return GetRimHeight() + 1.0; // TODO - GUESSES! - tune this
}
return 0.0;
}
//
// Returns the target point value
//
int Target::GetPointValue() {
switch (id) {
case Bottom : return 1;
case Left : return 2;
case Right : return 2;
case Middle : return 2;
case Top : return 3;
}
return 0;
}
//
// Returns the target identifer
//
Target::ID Target::GetIdentifier() {
return id;
}
//
// Returns the horizontal angle necessary to turn to center the target
//
float Target::GetHorizontalAngle() {
return hAngle;
}
//
// Set the horizontal angle necessary to tern to center the target
//
void Target::SetHorizontalAngle(float angle) {
hAngle = angle;
}
//
// Return string prepresentation of the target. Do not free char * returned.
//
const char * Target::AsString() {
char buffer[64];
switch (id) {
case Bottom : strcpy("Bottom", buffer);
case Left : strcpy("Left", buffer);
case Right : strcpy("Right", buffer);
case Middle : strcpy("Middle", buffer);
case Top : strcpy("Top", buffer);
}
sprintf(stringRep, "%s Rim:%0.3f Arc:%0.3f hAngle:%0.1f", buffer, GetRimHeight(),
GetArcHeight(), GetHorizontalAngle());
return stringRep;
}