Average'd rotation

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Shrimp

Seafood splatter
Jan 13, 2003
740
0
16
41
Deep in South Africa
shrimpworks.za.net
Hiya.

I am trying to set an actor's rotation based on an average rotation over the past few frames and having a bit of trouble.

Each Tick the actor's current rotation is appended to an array of type Rotator, and the first item in the array is knocked off while the others are shifted up a position. The contents of the array are all added up into a single rotator, then divided by the number of frames/items in the array, which gives me an average. The actor's rotation is then set to that average rotation value.

That all works 100% perfectly, EXCEPT when the actor rotates around an area where the Yaw is near 0 and 65535 (where the Yaw value 'ends' and 'starts'). That's becuase the rotation is now being average'd out over a range of 65535 and 0, so when the array is added up and divided, it ends up with a rotation of exactly opposite what to it should actually be for a few frames, creating a really nasty flicking effect.

I have tried using Quat rotation based on functions found in the Wiki, but found you can't add multiple Quats together, and therefore I can't get an average. I have little to know knowledge in this area though, so maybe there is something I am missing here.

Any suggestions or help would be appreciated, thanks.
 

Mychaeel

New Member
The notion of an "average rotation" is a bit difficult in itself. Just think: If you had two rotators pointing in opposite directions, what would be the proper average of them?

Perhaps it'd be better to tackle this problem of an "average rotation" by converting each rotator to a vector, averaging those vectors and then converting the resulting vector back to a rotator.
 

Shrimp

Seafood splatter
Jan 13, 2003
740
0
16
41
Deep in South Africa
shrimpworks.za.net
Hmm, I actually tried storing the rotation 'buffer' in an array of Vectors rather than Rotators before (and converting final average to a Rotator), but came across the same problem.

Funny thing now is, I store the array as Rotators, convert to Vectors and work out the average, and apply the final vector as a rotator - and it works!!

Amazing, thanks a lot for the different view on it ;)