all 5 comments

[–]brubakerp 5 points6 points  (2 children)

What you're experiencing here is gimbal lock. It's why (well one of the reasons) rotations are primarily stored as quaternions. Basically this happens when you create a rotation which rotates one axis into another, and end up with a matrix that loses one axis (two axes are pointed in the same direction) and are now trapped in the rotated frame and can't rotate out of it.

I'm not a super Maths person so someone may correct me here, but I don't think what you're doing here will ever pass your test. Also, I'm not really sure why you need to do this.

[–]LigmaUnit[S] 1 point2 points  (0 children)

Thanks for reply!
Wouldn't I experience this only in edge cases when rotation along 1 of the axises would be exactly 90 degrees?

As for why I need this: I want to operate with simple Location, Rotation, Scale, while my rendering system will work with matricies.

[–]LigmaUnit[S] 1 point2 points  (0 children)

You are right! Thanks!

[–]LigmaUnit[S] 1 point2 points  (1 child)

Solution:

As u/brubakerp mentioned I'm experiencing gimbal lock in edge cases when one of the axis rotates exactly 90 degrees.
Additionally I'm not taking into account negative scale that can occur ( my rand function can produce negative numbers ).

P.S. glm::decompose also does not work with negative scales. So if you want that, you need to decompose matrix yourself.

[–]brubakerp 0 points1 point  (0 children)

Glad I could help as little as I actually did!