_I'm no expert, so take this with a grain of salt._
Godot version:
master branch
OS/device including version:
N/A
Issue description:
There appears to be a flaw in the calculation for converting YPR angles to quaternions. In Quat::set_euler_yxz it's specifying the z component as
-sin_a1 * sin_a2 * cos_a3 + cos_a1 * sin_a2 * sin_a3
but, unless I'm mistaken, it should be
-sin_a1 * sin_a2 * cos_a3 + cos_a1 * cos_a2 * sin_a3
Steps to reproduce:
... look at the code?
Minimal reproduction project:
Like I said, I'm no expert in this, and unfortunately I can't test it (I can't run Godot on this machine), so I may be way off the mark, but I figured this issue can just be closed if I am wrong.
CC @tagcup
As a note, the PYR conversion looks correct.
Can you check the NASA doc? I remember putting a reference link inside the comments, along with the page number. Please correct it if they don't agree.
I did double check with the NASA doc, as well as a Java transform library I have locally. That's how I noticed the discrepancy.
Thanks for noticing it, I for sure didn't (that was my mistake). So could you submit a PR for it?
There's probably a copy of that in C# code too that needs fixing BTW
I would have no way of building or testing the PR, so it would probably be better to have someone who can do it. I just noticed it as I was reading through the code on GitHub.
You just need to replace a sin with cos so I wouldn't worry about it. Also, when you submit a PR, the CI system will compile it for you automatically (on multiple platforms, it's quite cool actually).
BTW, I just realized that Quat::get_euler_* and xform are super inefficient, and can be written in a way that is much faster. If you like to do it, feel free, otherwise I can do it during the weekend.
I'll let you take care of it. One of these days, when I can get back into game development, I'll try to contribute more.
Most helpful comment
You just need to replace a sin with cos so I wouldn't worry about it. Also, when you submit a PR, the CI system will compile it for you automatically (on multiple platforms, it's quite cool actually).
BTW, I just realized that Quat::get_euler_* and xform are super inefficient, and can be written in a way that is much faster. If you like to do it, feel free, otherwise I can do it during the weekend.