forked from CBA2011/WASABIEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EmotionConverter.cc
187 lines (172 loc) · 5.53 KB
/
EmotionConverter.cc
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/********************************************************************************
**
** [W]ASABI [A]ffect [S]imulation [A]rchitecture for [B]elievable [I]nteractivity
**
** Copyright (C) 2011 Christian Becker-Asano.
** All rights reserved.
** Contact: Christian Becker-Asano (christian@becker-asano.de)
**
** This file is part of the WASABIEngine library.
**
** The WASABIEngine library is free software: you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** The WASABIEngine library is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public License
** along with the WASABIEngine library. If not, see <http://www.gnu.org/licenses/>
**
********************************************************************************/
#include "EmotionConverter.h"
#include <stdlib.h>
using namespace std;
/*!
* Leerer Konstruktor.
*/
EmotionConverter::EmotionConverter()
{
}
/*!
* Leerer Destruktor.
*/
EmotionConverter::~EmotionConverter()
{
}
/*!
* Initialisierung der stringConvertMap
*/
EmotionConverterPAD::EmotionConverterPAD()
: EmotionConverter()
{
//nothing
}
/*!
* Leerer Destruktor.
*/
EmotionConverterPAD::~EmotionConverterPAD ()
{
}
// /*!
// * Hier wird die Abbildung K(xt, yt, zt, t), wie in der Diploamarbeit beschrieben, vorgenommen.
// */
// std::vector<float>
// EmotionConverterPAD::convertToClassType(std::vector<float> foreignData)
// {
// std::vector<float> v;
// if (foreignData.size() == 4){
// float emoX = foreignData[0];
// float moodY = foreignData[1];
// float boredomZ = foreignData[2];
// float dominance = foreignData[3];
// float pValue = ((emoX + moodY) / 200);
// float aValue = fabs(emoX / 100) - fabs(boredomZ / 100);
// float dValue = dominance / 100;
// v.push_back(pValue);
// v.push_back(aValue);
// v.push_back(dValue);
// }
// return v;
// }
/*!
* Hier wird die Abbildung K(xt, yt, zt, t), wie in der Diploamarbeit beschrieben, vorgenommen.
* NEW: Integer values are sufficient!
*/
std::vector<int>
EmotionConverterPAD::convertToClassType(std::vector<int> foreignData)
{
std::vector<int> v;
if (foreignData.size() == 4){
int emoX = foreignData[0];
int moodY = foreignData[1];
int boredomZ = foreignData[2];
int dominance = foreignData[3];
int pValue = ((emoX + moodY) / 2);
// 19th of May 2009: next line was "int aValue = emoX - boredomZ;" before.
// But boredomZ is negatively signed after EmotionDynamics::update and we need to use the absolute value of emoX, of course.
// Why did this ever work with this bug before?
int aValue = abs(emoX) + boredomZ;
int dValue = dominance;
v.push_back(pValue);
v.push_back(aValue);
v.push_back(dValue);
}
return v;
}
/*!
* We try our best here.
*/
std::vector<float>
EmotionConverterPAD::convertFromClassType(std::vector<float> PADData)
{
std::vector<float> v;
if (PADData.size() >= 3) {
int p = (int)((float)PADData[0] * 100);
int a = (int)((float)PADData[1] * 100);
int d = (int)((float)PADData[2] * 100);
int x = 0;
int y = 0;
int z = 0;
if (a < 0) {
z = a;
}
else {
x = a; // Must be +/- a!
}
y = 2 * p;
if (y + x > 100)
x *= -1;
else {
if (y - x > -100) {
cerr << "EmotionConverterPAD::convertFromClassType: We have a problem!" << endl;
if (y < 0)
x *= -1;
}
}
y += x;
x *= -1;
cout << "Matching PAD (" << p << ", " << a << ", " << d << ") to XYZ (" << x << ", " << y << ", " << z << ")" << endl;
v.push_back(x);
v.push_back(y);
v.push_back(z);
}
else
cerr << "EmotionConverterPAD::convertFromClassType: wrong size of input vector!" << endl;
// cerr << "WARNING: EmotionConverterPAD::convertFromClassType not implementable!" << endl;
return v;
}
/*!
* Liefert den Namen der Emotionkategorie, die am naechsten liegt!
*/
/* WIN32 obsolete!!!
std::string
EmotionConverterPAD::toString(std::vector<int> PADData){
std::string s = "verwirrt";
cout << "EmotionConverterPAD::toString: WARNING This function is obsolete! *********************************" << endl;
// int counter = 0;
// emoIndex = -1;
// if (PADData.size() == 3){
// StringVectorMMap::iterator it;
// emoDistance = 10.0;
// for (it = stringConvertMap.begin(); it != stringConvertMap.end(); ++it){
// float a = (float)PADData[0] / 100 - it->second[0];
// float b = (float)PADData[1] / 100 - it->second[1];
// float c = (float)PADData[2] / 100 - it->second[2];
// float tempDistance = sqrt(pow(c, 2) + pow(a, 2) + pow(b, 2));
// //cout << "a = " << a << ", b = " << b << ", c = " << c << "--> tempDistance = " << tempDistance << " bei " << it->first << endl;
// if (tempDistance <= emoDistance && tempDistance <= outerRadius){
// s = it->first;
// emoDistance = tempDistance;
// emoIndex = counter;
// }
// ++counter;
// }
// }
//cout << "EmotionConverterPAD::toString: s = " << s << endl;
return s;
}
*/