▲ | Etherlord87 4 days ago | |||||||
Don't worry about negative comments, yes, this is not the best way, but (if there's no error, I didn't analyze it thoroughly) it's often good enough; if it works, then it works. I once wanted to find a vector for which Euler rotation (5°, 5°, 0) will result with the same vector, so I just ran a loop of million iterations or so which would take a starting vector, translate it randomly slightly (add a small random vector) and see if after rotation it's closer to original than the previous vector would be after rotation, if not, discard the change otherwise keep it. The script ran for a couple seconds on Python and with decreasing translation vector based on iteration number, I got perfect result (based on limited float precision of the vector). 2s would be terribly slow in a library but completely satisfying for my needs :D | ||||||||
▲ | jjcob a day ago | parent | next [-] | |||||||
Thank you for your encouragement :) I read a bit more about the topic, and it seems that the issue with my approach is that the decimal representation might end up exactly halfway between two floats, and then the result of parsing it depends on the rounding mode that the parser uses. (By default scanf should use round-to-even, but I'm not sure all implementations do so) In the PostgreSQL docs I found a curious fact: They use an algorithm that makes sure the printed decimal is never exactly half way between two representable floats, so the result of scanning the decimal representation doesn't depend on the rounding mode. | ||||||||
▲ | oasisaimlessly 4 days ago | parent | prev | next [-] | |||||||
FYI, you can solve your problem in closed form by converting your Euler angles into the 'rotation vector'[1] or 'axis-angle'[2] representations and then normalizing the resulting vector. [1]: https://en.wikipedia.org/wiki/Axis%E2%80%93angle_representat... [2]: https://en.wikipedia.org/wiki/Axis%E2%80%93angle_representat... | ||||||||
| ||||||||
▲ | Sharlin 4 days ago | parent | prev [-] | |||||||
I guess that's faster than working out the eigenvectors by hand. |