Intersection of trajectories in 3D

How can i find the intersection (which is unlikely in 3D) or the closest points of trajectories in 3D?
I have discrete time series data of 3 variables for several initial conditions. I want to draw a plot of these three variables, for different initial conditions(let's say 2 at the beginning) and check if they intersect? (or kind of intersect)
How can I do this using MATLAB?
Thank you very much in advance.

2 Comments

Are you assuming straight line travel between the points?
No, they are not straight trajectories. I am still trying to find a way.

Sign in to comment.

 Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 21 Oct 2012
Edited: Azzi Abdelmalek on 21 Oct 2012
v1=[x1 y1 z1] % trajectory 1
v2=[x2 y2 z2] % trajectory 2
plot3(x1,y1,z1)
hold on;plot3(x2,y2,z2,'r')
idx=find(~all(v1-v2,2)) % gives the indedx idx corresponding to exact intersection
[c,idxc]=min(sum(abs(v1-v2),2)) % gives the closest point:index idxc

2 Comments

Thank you very much. Yet, this doesn't work. The data at hand describes population dynamics and therefore has all zero columns for both trajectories.
Yigit
Yigit on 23 Oct 2012
Edited: Yigit on 23 Oct 2012
Hi, I have two parametric curves defined in three dimensions, which are functions of a variable n (timesteps), like so:
x1 = f1(n) y1 = f2(n) z1 = f3(n)
x2 = f4(n) y2 = f5(n) z2 = f6(n)
I need to find if they intersect or somehow gets too close and follows the same route for a certain time.

Sign in to comment.

More Answers (0)

Categories

Products

Community Treasure Hunt

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

Start Hunting!