Moving 3d cube using Quaternions

6 views (last 30 days)
Matlab_Go
Matlab_Go on 12 Feb 2020
Hi,
I am using the following example Track Orientation to visualize a cube / sensor object and it's position should be updated with the sensor incomings. I adapted the example in the following way:
  1. I am not using BLE but I want to update the position with the reading of a sensor file which includes gyro_data(x,y,z).
  2. It means for every iteration I am reading one line which consists of gx,gy and gz and I want to update the position. This works fine! --> I am able to read whenever I need one line and get the values out.
  3. I do not want to use rotations matrices but quaternions, since it is more efficient and easier using them. What I am doing is the following approach:
a) Assume that initial po is (1,0,0,0) and take this as start position.
b) read one line from file and update q (important is that q is normalized)--> after updating q, I am performing the point rotation method rotatepoint(q,[x,y,z]) which depicts the following function : qvq*. See this thread: Information to all the vertices of the patches of the cube.
My problem is that I do not know how to update the points so that the cube is moving. I checked the approach used in the example mentioned above, but they are using rotation matrices and I do not understand how it works. Is there maybe a way to update the points applying only quaternions. what I was trying to do is to update the vertices /overwrite them with the new value and display it with drawnow, but the movements are not correct. Can someone give me a hint how to do it?

Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!