<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240824</link>
    <title>MATLAB Central Newsreader - How to synchronize two 3D Trajectories</title>
    <description>Feed for thread: How to synchronize two 3D Trajectories</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Thu, 11 Dec 2008 02:12:02 -0500</pubDate>
      <title>How to synchronize two 3D Trajectories</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240824#616311</link>
      <author>smar </author>
      <description>Hello,&lt;br&gt;
There are two 3D Trajectories in Matlab. &lt;br&gt;
A = [x y z]   rows = n   (about 20,000)&lt;br&gt;
B = [x y z]   rows = m   (about 50,000)&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Both trajectories A and B represent a same 3D path in space. Thus all 3D points on trajectory A should have their corresponding 3D points in trajectory B.&lt;br&gt;
&lt;br&gt;
Both trajectories are generated from different sources. &lt;br&gt;
There are two constraints:&lt;br&gt;
&lt;br&gt;
1.	There are small deviations (in ?m) in corresponding x y and z values of corresponding 3D points.&lt;br&gt;
&lt;br&gt;
2.	There is a small shift (variable along the trajectory) in relative position of corresponding 3D points in trajectories. In other words separation between points (point&amp;#8217;s density) is different over the trajectory.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
The final task is to calculate these deviations. But first problem is to find the corresponding points in both trajectories (synchronizing the both trajectories or searching for the matching points). &lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Finally the deviation would be calculated such as:&lt;br&gt;
For example &lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;Points in A   - corresponding points in B =   deviations&lt;br&gt;
--&lt;br&gt;
--&lt;br&gt;
--&lt;br&gt;
&lt;br&gt;
[34.00 56.05 67.06] - [34.01 56.04 67.07] = [-00.01 00.01 -00.07]&lt;br&gt;
[34.50 56.55 67.50] - [34.52 56.57 67.48] = [-00.02 -00.02 00.02]&lt;br&gt;
[34.70 56.75 67.76] - [34.71 56.74 67.77] = [-00.01 -00.01 -00.01]&lt;br&gt;
--&lt;br&gt;
--&lt;br&gt;
--&lt;br&gt;
&lt;br&gt;
Need guideline/Help needed &lt;br&gt;
&lt;br&gt;
&amp;#8226;	How I can syschronize the trajectories or find the maching points for trajectory A in trajectory B (any Matlab functions or methods ?)&lt;br&gt;
Thanks in advance for an expected help&lt;br&gt;
&lt;br&gt;
Regards</description>
    </item>
    <item>
      <pubDate>Thu, 11 Dec 2008 03:10:54 -0500</pubDate>
      <title>Re: How to synchronize two 3D Trajectories</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240824#616318</link>
      <author>NZTideMan</author>
      <description>On Dec 11, 3:12=A0pm, &quot;smar &quot; &amp;lt;smar...@yahoo.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; Hello,&lt;br&gt;
&amp;gt; There are two 3D Trajectories in Matlab.&lt;br&gt;
&amp;gt; A =3D [x y z] =A0 rows =3D n =A0 (about 20,000)&lt;br&gt;
&amp;gt; B =3D [x y z] =A0 rows =3D m =A0 (about 50,000)&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Both trajectories A and B represent a same 3D path in space. Thus all 3D =&lt;br&gt;
points on trajectory A should have their corresponding 3D points in traject=&lt;br&gt;
ory B.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Both trajectories are generated from different sources.&lt;br&gt;
&amp;gt; There are two constraints:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; 1. =A0 =A0 =A0There are small deviations (in ?m) in corresponding x y and=&lt;br&gt;
&amp;nbsp;z values of corresponding 3D points.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; 2. =A0 =A0 =A0There is a small shift (variable along the trajectory) in r=&lt;br&gt;
elative position of corresponding 3D points in trajectories. In other words=&lt;br&gt;
&amp;nbsp;separation between points (point=92s density) is different over the trajec=&lt;br&gt;
tory.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; The final task is to calculate these deviations. But first problem is to =&lt;br&gt;
find the corresponding points in both trajectories (synchronizing the both =&lt;br&gt;
trajectories or searching for the matching points).&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Finally the deviation would be calculated such as:&lt;br&gt;
&amp;gt; For example&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; =A0 Points in A =A0 - corresponding points in B =3D =A0 deviations&lt;br&gt;
&amp;gt; --&lt;br&gt;
&amp;gt; --&lt;br&gt;
&amp;gt; --&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; [34.00 56.05 67.06] - [34.01 56.04 67.07] =3D [-00.01 00.01 -00.07]&lt;br&gt;
&amp;gt; [34.50 56.55 67.50] - [34.52 56.57 67.48] =3D [-00.02 -00.02 00.02]&lt;br&gt;
&amp;gt; [34.70 56.75 67.76] - [34.71 56.74 67.77] =3D [-00.01 -00.01 -00.01]&lt;br&gt;
&amp;gt; --&lt;br&gt;
&amp;gt; --&lt;br&gt;
&amp;gt; --&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Need guideline/Help needed&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; =95 =A0 =A0 How I can syschronize the trajectories or find the maching po=&lt;br&gt;
ints for trajectory A in trajectory B (any Matlab functions or methods ?)&lt;br&gt;
&amp;gt; Thanks in advance for an expected help&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Regards&lt;br&gt;
&lt;br&gt;
If there were a 4th dimension (time) the problem would be trivial:&lt;br&gt;
you'd interpolate for the time in A for each of the dimensions, using&lt;br&gt;
B.&lt;br&gt;
In the absence of time, one way would be to find the nearest point in&lt;br&gt;
B corresponding to each point in A.&lt;br&gt;
dev=3Dzeros(nz,3);&lt;br&gt;
for ia=3D1:na&lt;br&gt;
[dmn,ib]=3Dmin((xb-xa(ia)).^2 + (yb-ya(ia)).^2 + (zb-za(ia)).^2);&lt;br&gt;
dev(ia,:)=3D[xb(ib)-xa(ia) yb(ib)-ya(ia) zb(ib)-za(ia)];&lt;br&gt;
end</description>
    </item>
    <item>
      <pubDate>Sat, 13 Dec 2008 18:34:02 -0500</pubDate>
      <title>Re: How to synchronize two 3D Trajectories</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240824#616830</link>
      <author>smar </author>
      <description>&lt;br&gt;
Hello&lt;br&gt;
Thanks for a very useful replay&lt;br&gt;
&lt;br&gt;
Yes there is a 4th dimension (time) too. &lt;br&gt;
But I guess, it can not be taken to compare A and B. Because there is a small time shift in both trajectories. Also:&lt;br&gt;
DeltaT of a certain pair of  2 connective points in A could be different to -------- DeltaT of their corresponding points. &lt;br&gt;
&lt;br&gt;
I have implemented point matching (based on minimum 3D distance suggested by NZTideMan ). It worked fine as all indices of all matching points are in ascending order. &lt;br&gt;
&lt;br&gt;
But there could still be one thing: &lt;br&gt;
As there are small deviation between corresponding points. Minimum distance point matching may results some time in wrong matches (matching neighbourhood points)&lt;br&gt;
&lt;br&gt;
How I can make this robust?&lt;br&gt;
Or there should be some alternative method?&lt;br&gt;
&lt;br&gt;
I would be very thankful for any further assistance.&lt;br&gt;
Regards&lt;br&gt;
Smar</description>
    </item>
    <item>
      <pubDate>Sat, 13 Dec 2008 22:32:27 -0500</pubDate>
      <title>Re: How to synchronize two 3D Trajectories</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240824#616852</link>
      <author>NZTideMan</author>
      <description>On Dec 14, 7:34=A0am, &quot;smar &quot; &amp;lt;smar...@yahoo.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; Hello&lt;br&gt;
&amp;gt; Thanks for a very useful replay&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Yes there is a 4th dimension (time) too.&lt;br&gt;
&amp;gt; But I guess, it can not be taken to compare A and B. Because there is a s=&lt;br&gt;
mall time shift in both trajectories. Also:&lt;br&gt;
&amp;gt; DeltaT of a certain pair of =A02 connective points in A could be differen=&lt;br&gt;
t to -------- DeltaT of their corresponding points.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I have implemented point matching (based on minimum 3D distance suggested=&lt;br&gt;
&amp;nbsp;by NZTideMan ). It worked fine as all indices of all matching points are i=&lt;br&gt;
n ascending order.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; But there could still be one thing:&lt;br&gt;
&amp;gt; As there are small deviation between corresponding points. Minimum distan=&lt;br&gt;
ce point matching may results some time in wrong matches (matching neighbou=&lt;br&gt;
rhood points)&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; How I can make this robust?&lt;br&gt;
&amp;gt; Or there should be some alternative method?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I would be very thankful for any further assistance.&lt;br&gt;
&amp;gt; Regards&lt;br&gt;
&amp;gt; Smar&lt;br&gt;
&lt;br&gt;
Providing the times of each trajectory are accurate and have the same&lt;br&gt;
start time, it doesn't matter that the time intervals are different:&lt;br&gt;
you just use time as a parameter like this:&lt;br&gt;
ti=3D[0:dt:tfin]';&lt;br&gt;
xai=3Dinterp1(xa,ta,ti);&lt;br&gt;
yai=3Dinterp1(ya,ta,ti);&lt;br&gt;
zai=3Dinterp1(za,ta,ti);&lt;br&gt;
xbi=3Dinterp1(xb,tb,ti);&lt;br&gt;
ybi=3Dinterp1(yb,tb,ti);&lt;br&gt;
zbi=3Dinterp1(zb,tb,ti);&lt;br&gt;
&lt;br&gt;
devx=3Dxai-xbi;&lt;br&gt;
devy=3Dyai-ybi;&lt;br&gt;
devz=3Dzai-zbi;</description>
    </item>
    <item>
      <pubDate>Sun, 14 Dec 2008 15:01:42 -0500</pubDate>
      <title>Re: How to synchronize two 3D Trajectories</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240824#616940</link>
      <author>smar </author>
      <description>&lt;br&gt;
Thank again for an usful reply, &lt;br&gt;
&lt;br&gt;
I think if I do like this&lt;br&gt;
&lt;br&gt;
devx=3Dxai-xbi;&lt;br&gt;
devy=3Dyai-ybi;&lt;br&gt;
devz=3Dzai-zbi;&lt;br&gt;
&lt;br&gt;
It is possible that xai-xbi aare  not the right corresponding points. &lt;br&gt;
&lt;br&gt;
To explain more, Trajectory A is a reference trajectory which is fed to controller and Trajectory B is real trajectory which is measured through sensors. &lt;br&gt;
&lt;br&gt;
Trajectory A -------fed to controller ------- Trajectory B (measured)&lt;br&gt;
&lt;br&gt;
Controller produced uneven and variable delays over the whole processing. &lt;br&gt;
Finally is may happen that: &lt;br&gt;
Trajectory A &amp;#8230;&amp;#8230; completion time is 20 seconds&lt;br&gt;
Trajectory B &amp;#8230;&amp;#8230; completion time is 20.05 seconds&lt;br&gt;
&lt;br&gt;
Now time 0.05 second is time shift which is accumulated sum of many variable delays through out the trajectory. &lt;br&gt;
&lt;br&gt;
I appreciate for any further assistance to my problem. &lt;br&gt;
Best wishes&lt;br&gt;
smar</description>
    </item>
  </channel>
</rss>

