Code Monkey home page Code Monkey logo

Comments (4)

DanielChappuis avatar DanielChappuis commented on May 24, 2024

Hello.

The library does not offer a way to get Euler angles from a quaternion. You can get the axis of rotation and angle around this axis using the Quaternion::getRotationAngleAxis() method.

Note that you should really try to work with quaternions for orientation instead of Euler angles but if you really want to extract Euler angles from the quaternion, you need to it yourself. For instance, you might try to use this.

Could you please post your questions in the Discussions section instead of opening an issue.

from reactphysics3d.

TheBoneJarmer avatar TheBoneJarmer commented on May 24, 2024

Thanks a lot for your reply and my apologies for not using the discussions section. Should I have any questions in the future, I will use the discussions section.

I gave that method a try but the values make no sense to me. I expected a vec3 containing the yaw, pitch, roll values in radians. Which in turn I could translate to a degree between 0 and 360. However, what I get instead is an angle and an axis. How can I convert that angle and axis to yaw, pitch and roll?

That said, I also would like to share that since I opened up this issue I decided to invest more time in learning more about quaternions and euler angles. And so far I have to admit I became more confused than wiser. I thought euler angles were the yaw, pitch and roll I talked about in my last paragraph but I have seen SO articles and blog posts that made me believe otherwise. On top of that when I make a quaternion using the values 45, 270 and 180 (in radians obviously) respectively I don't get the desired result. So it only confirms my expectation that euler angles are not the same as yaw, pitch and roll.

Note that you should really try to work with quaternions for orientation instead

This I learned as well. It seems more clear to make that using quaternions instead of euler angles is the best decision. I kept reading over and over that using euler angles could result in a so called Gimbal lock right? I have yet to learn the subject. Speaking of, if that is okay with you I like to ask some questions here related to quaternions. You are definitely the expect on the subject here and like I mentioned, researching it myself made me more confused. I am not a math expert and I like to stick to the upmost basics. I am willing to learn however what I must but I learn best by example and not so much from a book. So please, do not refer me to a complicated wiki page. I have seen those enough by now. lol

  • Are euler angles the same as yaw, pitch and roll? If not, how can I convert yaw, pitch and roll to euler?
  • If possible to explain briefly, what is the Gimbal lock?
  • Is the order of axis angles relevent in a quaternion and if so, are you using the XYZ standard?

I am cool with opening up an discussions thread as well with the above questions if you desire so. But I figured since I already (wrongly) opened this issue here, I might as well use this thread.

from reactphysics3d.

TheBoneJarmer avatar TheBoneJarmer commented on May 24, 2024

So hey, as a follow up. I still have not figured out how to convert a quaternion to euler angles and after days of research I decided to give up the idea of easing euler angles at all. Henceforth I decided to throw out that part and convert every rotation in my library from Vector3 to Quaternion. And this solved my problem too.

Also, I was able to use GLM to construct a model matrix from your Quaternion class resulting in cubes that now rotate very fluently and correctly. And thanks to your Quaternion::fromEulerAngles method I was able to construct quaternions as well. So my needs are covered.

from reactphysics3d.

DanielChappuis avatar DanielChappuis commented on May 24, 2024

Hi, I am glad that you figured something out. You will see that working with quaternions is much better for computer graphics even if it seems difficult to directly see what this mathematical object represent in 3D.

Here are some articles that can be useful to learn about quaternions:

from reactphysics3d.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.