Plotting orientation in 3-D plot

10 views (last 30 days)
JP
JP on 24 Jun 2013
Hello, Im recording data for the orientation (direction) a tool is pointing in. I already have everything set up to give me the data with euler angles and such. Currently, I have my code set up so that my graph displays a dot at the POSITION the instrument is at. But unfortunately, that lacks the direction the instrument is pointing in. Here is my current code for the instrument positioning
figure(1)
plot3(data.Tx,data.Ty,data.Tz,'r*',data.Tx2,data.Ty2,data.Tz2,'b*')
xlim([-200 200]);
ylim([-200 200]);
zlim([-1000 -500]);
drawnow
So I get a realtime position of the tool. I am hoping I can somehow change the 'r*' (which plots a red star where the tool is) into a vector. I dont know what command to use. Of course, I have data giving the orientation, which from my code is
data.Q0=str2double(datastr(5:10))/10000;
data.Qx=str2double(datastr(11:16))/10000;
data.Qy=str2double(datastr(17:22))/10000;
data.Qz=str2double(datastr(23:28))/10000;
data.Q02=str2double(datastr(75:80))/10000;
data.Qx2=str2double(datastr(81:86))/10000;
data.Qy2=str2double(datastr(87:92))/10000;
data.Qz2=str2double(datastr(93:98))/10000;
So all in all, I would most appreciate it if someone could give me the function for plotting a vector when I have the angles, thanks! (the last bit are in quaternions....I have code which changes them into Euler angles so just give me the answer in angles if that is easier)
Oh and also, maybe we dont even need to use the angles and can just use the positions instead? Perhaps that is even easier. Since Im measuring from a camera which is giving me those coordinates, the negative of the position vector would probably work as long as I made it a shorter vector in the same direction.
  2 Comments
Jan
Jan on 3 Jul 2013
The question is not clear: What are the fields "Q0, Qx, ..."? How are they related to the fields "data.Tx, .Ty, .Tz"? Neither the Eulerangles nor Quaternions are sufficient for drawing objects, while the direction cosin matrix contains the components to draw a 3D tripod already.
I do not understand how you want to handle "negative positions". What about multiplying the data by -1?
JP
JP on 3 Jul 2013
negative positions are fine...its all just relative to a certain coordinate system. Basically I solved this problem by defining an arbitrary vector and applying the inverse of the rotation matrix to it. From that I was able to use quiver3 to give a direction to what I wanted to plot

Sign in to comment.

Accepted Answer

JP
JP on 3 Jul 2013
Basically I solved this problem by defining an arbitrary vector and applying the inverse of the rotation matrix to it. From that I was able to use quiver3 to give a direction to what I wanted to plot

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!