mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:50:00 +02:00
additional merge
This commit is contained in:
commit
72bdf340e9
6 changed files with 78 additions and 80 deletions
|
@ -12,10 +12,11 @@
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <SharedUtil.h>
|
||||||
|
#include <StdDev.h>
|
||||||
|
#include <UDPSocket.h>
|
||||||
#include "Audio.h"
|
#include "Audio.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include <SharedUtil.h>
|
|
||||||
#include "UDPSocket.h"
|
|
||||||
|
|
||||||
Oscilloscope * scope;
|
Oscilloscope * scope;
|
||||||
|
|
||||||
|
|
|
@ -13,48 +13,6 @@
|
||||||
#include "world.h"
|
#include "world.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
|
|
||||||
//
|
|
||||||
// Standard Deviation Object
|
|
||||||
//
|
|
||||||
|
|
||||||
const int MAX_STDEV_SAMPLES = 1000; // Don't add more than this number of samples.
|
|
||||||
|
|
||||||
StDev::StDev() {
|
|
||||||
data = new float[MAX_STDEV_SAMPLES];
|
|
||||||
sampleCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void StDev::reset() {
|
|
||||||
sampleCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void StDev::addValue(float v) {
|
|
||||||
data[sampleCount++] = v;
|
|
||||||
if (sampleCount == MAX_STDEV_SAMPLES) sampleCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
float StDev::getAverage() {
|
|
||||||
float average = 0;
|
|
||||||
for (int i = 0; i < sampleCount; i++) {
|
|
||||||
average += data[i];
|
|
||||||
}
|
|
||||||
if (sampleCount > 0)
|
|
||||||
return average/(float)sampleCount;
|
|
||||||
else return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
float StDev::getStDev() {
|
|
||||||
float average = getAverage();
|
|
||||||
float stdev = 0;
|
|
||||||
for (int i = 0; i < sampleCount; i++) {
|
|
||||||
stdev += powf(data[i] - average, 2);
|
|
||||||
}
|
|
||||||
if (sampleCount > 1)
|
|
||||||
return sqrt(stdev/(float)(sampleCount - 1.0));
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the azimuth angle in degrees between two points.
|
// Return the azimuth angle in degrees between two points.
|
||||||
float azimuth_to(glm::vec3 head_pos, glm::vec3 source_pos) {
|
float azimuth_to(glm::vec3 head_pos, glm::vec3 source_pos) {
|
||||||
return atan2(head_pos.x - source_pos.x, head_pos.z - source_pos.z) * 180 / PI;
|
return atan2(head_pos.x - source_pos.x, head_pos.z - source_pos.z) * 180 / PI;
|
||||||
|
|
|
@ -24,17 +24,5 @@ void drawvec3(int x, int y, float scale, float rotate, float thick, int mono, gl
|
||||||
float r=1.0, float g=1.0, float b=1.0);
|
float r=1.0, float g=1.0, float b=1.0);
|
||||||
double diffclock(timeval *clock1,timeval *clock2);
|
double diffclock(timeval *clock1,timeval *clock2);
|
||||||
|
|
||||||
class StDev {
|
|
||||||
public:
|
|
||||||
StDev();
|
|
||||||
void reset();
|
|
||||||
void addValue(float v);
|
|
||||||
float getAverage();
|
|
||||||
float getStDev();
|
|
||||||
int getSamples() {return sampleCount;};
|
|
||||||
private:
|
|
||||||
float * data;
|
|
||||||
int sampleCount;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -915,30 +915,6 @@ int main(int argc, char** argv)
|
||||||
printf("Failed lookup domainserver\n");
|
printf("Failed lookup domainserver\n");
|
||||||
}
|
}
|
||||||
} else printf("Using static domainserver IP: %s\n", DOMAIN_IP);
|
} else printf("Using static domainserver IP: %s\n", DOMAIN_IP);
|
||||||
|
|
||||||
printf("Testing stats math... ");
|
|
||||||
StDev stdevtest;
|
|
||||||
stdevtest.reset();
|
|
||||||
stdevtest.addValue(1345);
|
|
||||||
stdevtest.addValue(1301);
|
|
||||||
stdevtest.addValue(1368);
|
|
||||||
stdevtest.addValue(1322);
|
|
||||||
stdevtest.addValue(1310);
|
|
||||||
stdevtest.addValue(1370);
|
|
||||||
stdevtest.addValue(1318);
|
|
||||||
stdevtest.addValue(1350);
|
|
||||||
stdevtest.addValue(1303);
|
|
||||||
stdevtest.addValue(1299);
|
|
||||||
|
|
||||||
if (stdevtest.getSamples() != 10)
|
|
||||||
printf("Samples=FAIL ");
|
|
||||||
|
|
||||||
if (floor(stdevtest.getAverage()*100.0) != 132859.0)
|
|
||||||
printf("Average=FAIL ");
|
|
||||||
|
|
||||||
if (floor(stdevtest.getStDev()*100.0) != 2746.0)
|
|
||||||
printf("Stdev=FAIL ");
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
// the callback for our instance of AgentList is attachNewHeadToAgent
|
// the callback for our instance of AgentList is attachNewHeadToAgent
|
||||||
agentList.linkedDataCreateCallback = &attachNewHeadToAgent;
|
agentList.linkedDataCreateCallback = &attachNewHeadToAgent;
|
||||||
|
|
48
shared/src/StdDev.cpp
Normal file
48
shared/src/StdDev.cpp
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
//
|
||||||
|
// StdDev.cpp
|
||||||
|
// hifi
|
||||||
|
//
|
||||||
|
// Created by Philip Rosedale on 3/12/13.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "StdDev.h"
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
const int MAX_STDEV_SAMPLES = 1000; // Don't add more than this number of samples.
|
||||||
|
|
||||||
|
StDev::StDev() {
|
||||||
|
data = new float[MAX_STDEV_SAMPLES];
|
||||||
|
sampleCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void StDev::reset() {
|
||||||
|
sampleCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void StDev::addValue(float v) {
|
||||||
|
data[sampleCount++] = v;
|
||||||
|
if (sampleCount == MAX_STDEV_SAMPLES) sampleCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
float StDev::getAverage() {
|
||||||
|
float average = 0;
|
||||||
|
for (int i = 0; i < sampleCount; i++) {
|
||||||
|
average += data[i];
|
||||||
|
}
|
||||||
|
if (sampleCount > 0)
|
||||||
|
return average/(float)sampleCount;
|
||||||
|
else return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
float StDev::getStDev() {
|
||||||
|
float average = getAverage();
|
||||||
|
float stdev = 0;
|
||||||
|
for (int i = 0; i < sampleCount; i++) {
|
||||||
|
stdev += powf(data[i] - average, 2);
|
||||||
|
}
|
||||||
|
if (sampleCount > 1)
|
||||||
|
return sqrt(stdev/(float)(sampleCount - 1.0));
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
27
shared/src/StdDev.h
Normal file
27
shared/src/StdDev.h
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
//
|
||||||
|
// StdDev.h
|
||||||
|
// hifi
|
||||||
|
//
|
||||||
|
// Created by Philip Rosedale on 3/12/13.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef __hifi__StdDev__
|
||||||
|
#define __hifi__StdDev__
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
class StDev {
|
||||||
|
public:
|
||||||
|
StDev();
|
||||||
|
void reset();
|
||||||
|
void addValue(float v);
|
||||||
|
float getAverage();
|
||||||
|
float getStDev();
|
||||||
|
int getSamples() {return sampleCount;};
|
||||||
|
private:
|
||||||
|
float * data;
|
||||||
|
int sampleCount;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* defined(__hifi__StdDev__) */
|
Loading…
Reference in a new issue