Comments (4)
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.
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.
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.
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:
- https://www.cs.utexas.edu/~fussell/courses/cs384g-spring2016/lectures/7a-Quaternions_Orientation.pdf
- https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation
from reactphysics3d.
Related Issues (20)
- How does the sensor need to be implemented? HOT 2
- mBaseAllocator.release pure virtual method called causing SIGABRT HOT 2
- A ton of compiler errors when trying to compile with Make. HOT 1
- RigidBody::raycast gives incorrect result in raycastInfo for body with multiple colliders + solution HOT 1
- Objects going though each other HOT 1
- Set Collider Transform assumes that mBody is a RigidBody HOT 2
- CollisionDetectionSystem::createContacts() assert crash HOT 2
- Transform::getOpenGLMatrix not including rotation HOT 2
- void PhysicsWorld::createIslands() dirty contactPairIndex crash HOT 4
- Will it work for Android? HOT 2
- testbed build error with glDisableVertexAttribArray
- Build failing - Missing include in configuration.h HOT 3
- Assertion failed in OverlappingPairs, version release 0.10.0 HOT 2
- Destroying an empty physics world leads to assertion failure (after upgrading to 0.10.0)
- 0.10.0 - Raycasting gives incorrect results for HeightFieldShape when scaling factor is applied HOT 1
- Child somewhat-static collision shape
- Ticking different objects at different rates
- v0.10.0: Assertion Failed in NarrowPhaseInfoBatch::addContactPoint() HOT 1
- Why is the collision not happening how I think it should? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reactphysics3d.