0
$\begingroup$

I want to rotate the whole value of a 3d vector into one axis using quaternion rotations.

The reason behind is that I want to align the X and Y Axis of my smartphone with the X and Y Axis of my vehicle in order to detect lateral and longitudinal acceleration separated on these two axis. Therefore I want to detect the first straight acceleration of the car and rotate the whole acceleration value into the heading axis (X-Axis) of the phone assuming a straight forward motion.

How do I achieve this?

enter image description here enter image description here

$\endgroup$
2
  • $\begingroup$ So you know the rotation you want to apply, but just don't know how quaternions work? $\endgroup$ – fibonatic Jun 8 '16 at 17:13
  • $\begingroup$ @fibonatic I know that if I accelerate forward for the first time with my car, I will get the corresponding sensor value mixed on two axes (e.g. X and Y-Axes). I also know the axis I would like to put the whole sensor value in (e.g. the X axis). $\endgroup$ – R. Doe Jun 8 '16 at 19:47
0
$\begingroup$
  • Use the average magnitude of X,Y as the acceleration vector.
  • Get the angle between this vector and the (1,0).
  • Create a quaternion with this vector that looks something like (cos(angle/2),0,0,-1)
  • Multiple all future acceleration results
$\endgroup$
1
  • $\begingroup$ That is sort of the way I used to do it now. Thank you! $\endgroup$ – R. Doe Jun 10 '16 at 7:12

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.