Note that there are some explanatory texts on larger screens.

plurals
  1. POAttitude change - angles and axis issue - quaternion math
    primarykey
    data
    text
    <p>I have an app that records angles as user is walking around an object, while pointing device (preferably) at the center of the object. Angle gets reset on user's command - so reference attitude gets reset.</p> <p>Using Euler angles produces Gimbal lock, so I am currently using quaternions and calculating angles this way:</p> <pre><code>double angleFromLastPosition = acos(fromLastPositionAttitude.quaternion.w) * 2.0f; </code></pre> <p>This gives off good precision and it works perfectly IF device's pitch and yaw does not change. In other words, as the angle shows 360 degrees I end up in the same place as the start of the circle.</p> <p>Problem 1: if device's yaw and pitch change slightly (user not pointing directly at center of the object), so does the angleFromLastPosition. I understand this part, as my angle formula just shows the angle in between two device attitudes in 3D space. </p> <p>Scenario:</p> <ul> <li>I mark the start of rotation attitude and start moving in a circle around the object while pointing at the center</li> <li>I stop at, say, 45 degrees and change pitch of the device by pointing it higher or lower. Angle changes accordingly.</li> <li>What I would love to see is: angle stays at 45 degrees, even if pitch or yaw changes.</li> </ul> <p>Question 1 is, how can I calculate only the Roll of the device using quaternions, and disregard changes in other two axes (at least within some reasonable number of degrees). </p> <p>Problem 2: if I rotate for a bit and then freeze the device completely (on tripod so there's no shaking at all), the angleFromLastPosition drifts at a rate of 1 degree per about 10-20 seconds, and it appears not to be linear. In other words, it drifts fast at first, then slows down considerably. Sometimes I get no drift at all - angle is rock-solid if device is stationary. And this makes me lost in understanding what's going on.</p> <p>Question 2, what is going on here, and how can I take care of the drift?</p> <p>I went through quite a few articles and tutorials, and quaternion math is beyond me at the moment, hope someone will be able to help with a tip, link, or few lines of code.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload