Trying to solve the issues I have with rotation matrices and quaternions

Hello guys!

Hello guys!

First of all. this is a big post, so I apologize for its size. Sorry for my bad grammar, its 3:00 am here and I’m sleepy.

I’m expanding my skill mechanic and I’ve tried to use both quaternions and affine transformations/rotation matrices to do the job, using my mathematical knowledge I’ve learned long ago, on my university.

My goal is to make the captured actors (the cubes in this video) to orbit the black hole elliptically, moving not only on XY plane, but on any plane.

That’s why I initially tried to use FMatrix to compose rotation matrices. but I should use quaternions to do the job, to avoid a gimbal lock. If I use matrices, I have to orthonormalize it, since multiple matrix multiplications can lead to a non-orthonormal matrix and to an respective accumulation of float point precision errors inside it. I looked for an example to rotate an object around another point than its own center using quaternions, but without success.

Yes, I read the FQuat documentation, as FMatrix as well. Both deal with multiplication in right-to-left manner (due to affine transformation’s nature). That’s why I used the composition M = T(x,y,z) x RotateZ x RotateY x RotateX x T(-x,-y,-z) x OrbitingActorLocation(x,y,z) to do the job.

Unfortunately, the documentation didn’t shed any light on my problem =S

I didn’t get any answer on UE4 Reddit and UE4 Forums, and I hope to get some help here, since I want to understand my errors here,

Here is the video: - YouTube

And here is the code:

.h:
https://pastebin.com/tiBjeWpX

.cpp
https://pastebin.com/d705gbts

Any help will be appreciated! =)

Thanks!

Hi! There are several ways to create this movement:

  • physics simulation with UE PhysX
  • manual iterational calculus of kinematic equations without PhysX (implemented in your classes)
  • managed movement on some parametric curves