Hello guys. I am using this to calculate the acceleration of a given vessel:
The problem is that there is a lot of oscillation, and the values suddenly spike up a lot in events such as touchdowns or dockings. It may be normal to have those values in a rigid touchdown, but they trigger the execution of the damage code. I have tried averaging:
But that doesn't help much. What's worse, if the sampling threshold is high enough, the system spits out insane values at the start of a simulation session and it takes it time depending on the threshold to settle down to more realistic values. Any suggestions?
Code:
VECTOR3 F, W, A;
GetForceVector(F);
GetWeightVector(W);
A = (F-W)/oapiGetMass(GetHandle());
The problem is that there is a lot of oscillation, and the values suddenly spike up a lot in events such as touchdowns or dockings. It may be normal to have those values in a rigid touchdown, but they trigger the execution of the damage code. I have tried averaging:
Code:
class LPFILTER
{
public:
LPFILTER()
{
fcThresh = 20;
}
LPFILTER(unsigned long fc)
{
fcThresh=fc;
}
int input(double d)
{
if (data.size()>fcThresh){
data.clear();
}
data.push_back(d);
return data.size();
}
double avg()
{
double sum = 0;
for (int i = 0; i < data.size(); i++)
{
sum+=data[i];
}
return (sum/data.size());
}
std::vector<double> data;
unsigned long fcThresh;
};
But that doesn't help much. What's worse, if the sampling threshold is high enough, the system spits out insane values at the start of a simulation session and it takes it time depending on the threshold to settle down to more realistic values. Any suggestions?