Y
Y
yatanai2022-02-01 23:13:42
Mathematics
yatanai, 2022-02-01 23:13:42

How to change rotation axes in quaternion?

I have an inertial sensor that outputs quaterions and an acceleration vector.
The controller is oriented as
Z - in gravity, X - "right" in the direction of view, Y - in the direction of view.
And the bottom line is that when I twist along the X axis, that is, I try to look up and down, then everything is ok. But the other axes are reversed. That is, if I spin the controller in Z, then in the game space it spins in Y and vice versa.

My goal is to swap rotation axes in a quaternion. How?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
yatanai, 2022-02-02
@yatanai

Suddenly, when I decided to indulge in permutations of variables in my code, everything was decided.
In my case, it was enough to swap the W and X components, and then invert X. (For me it rotated in the opposite direction)
That is, in the end I did (w, x, y, z) -> (x, -w, y, z)
I also googled someone else's code and found another permutation (w, x, y, z) ->(-y, x, z, w), but in my case it did not give the desired axes.
Some permutations completely break the engine and the space starts to collapse, so be careful

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question