Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

JeffNik

Smoothing a value over time

This topic is 5220 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m working on a VR game app, and I''ve finally got head orientation data coming from my HMD in terms of rotation about the X,Y and Z axes. The data coming in is fairly noisy: If I hold my head as still as possible, the image before me is "shaky" - it moves around in small apparently random "jumps". I used to have a magazine article that described a function that took samples over time and returned an approximated, smoothed value - but I think I tossed out the magazine. Can someone please post a code snippet that accomplishes this?

Share this post


Link to post
Share on other sites
Advertisement
Progressive averaging? Maintain an accumulator and a value count, and use the result of accumulator/count as your heading value. You''ll have to reset both every once in a while, to guard against overflow.

Share this post


Link to post
Share on other sites
1. Take the mean of the last n samples?

(Off the top of my head I can see several ways of optimising this; for small values of n possibly unnecessary)

2. Take the weighted mean of the last sample and the result from the previous cycle''s calculation:

V'' = (V * (1-c)) + (n*c);

V is the value to display and n is the input value?

Where c is some constant between 0 and 1 (probably closer to 0)

Essentially the effect of a given reading falls off exponentially or something. There is probably a name for this but I don''t know what it is.

Mark

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!