Archived

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

Smoothing a value over time

This topic is 5002 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
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