0
$\begingroup$

I'm working on a programming project, in this project I'm receiving an angle as a quaternion value, I partially understand how they work but I don't find any math to get the values I need.
What I would need is the angle between a fictional line/vector going to the the quaternion point from the origin (yes I know what you are thinking, but I couldn't think of a better explanation) and the "earth" a plane that is perpendicular to the gravitational vector, in this case one of your planes of reference.
Also I would need to get the rotation of the line/vector, this time the rotation should be according to the plane perpendicular to itself.
If possible all angles should be described as an angle between -180° and 180° (that's were my troubles are from.

If someone could help me by this it would be awesome
Thank you in advanced
~TJ

In this picture γ complementary angle of the first questing and R is the secondary angle.
Angles

$\endgroup$
  • $\begingroup$ Do you mean something like Conversion between quaternions and Euler angles? $\endgroup$ – Somos Jan 15 at 23:13
  • $\begingroup$ I actualy tried implementing that a few times but it did't give me a result between -180° and 180°, I alsways had -90° to 90°. These are the formulas I used. $\endgroup$ – Tim Jager Jan 16 at 6:12
  • $\begingroup$ gx = 2 * (xz - wy) || gy = 2 * (wx + yz) || gz = ww - xx - yy + zz || yaw = atan2(2*xy - 2*wz, 2*ww + 2*xx - 1) || pitch = atan(gx / sqrt(gygy + gzgz)) || float roll = atan(gy/gz) $\endgroup$ – Tim Jager Jan 16 at 6:19
  • $\begingroup$ You should always use atan2(y,x) instead of atan(y/x). It is a common mistake. $\endgroup$ – Somos Jan 16 at 14:59
  • $\begingroup$ That did it. Thank you Somos. $\endgroup$ – Tim Jager Jan 16 at 19:49
0
$\begingroup$

You should always use atan2(y,x) instead of atan(y/x). It is a common mistake. – @Somos

Thank you, apparently that did it!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.