3
\$\begingroup\$

I'm not sure if there's a better way to ask that, but I have a hovercraft which hovers by imparting force at each of four corners. I'd like to clamp the maximum variance between the thrusters so if one corner hovers over something higher altitude, the effect is less dramatic.

For example, if I had 4-6-8-10, I might want it to compress to 4-5-6-7.

\$\endgroup\$
3
\$\begingroup\$

I would actually recommend normalizing towards the mean (average) rather than the lowest value.

base_values = {4, 6, 8, 10};

double ave = average(base_values); // ave is equal to 7

for(int i = 0; i < base_values.len; i++)
{
    base_values[i] = base_values[i] - (abs(ave - base_values[i]) / 2);
}

abs(...) is the absolute value function.

That will make going down jagged terrain look good, as well as going up.

\$\endgroup\$
1
\$\begingroup\$

From what you posted I see a pattern you could use. Here is some psudocode

values = {4,6,8,10}

lowest = 100 //or some other imposible high number
for each int in values {
 if int < lowest then lowest = int
}

for each int in values {
 value = value -((lowest-value)/2)
}
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.