Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have two curves (drawn from points) in a plane, one is drawn with ListLinePlot and the other drawn with ParametricPlot. How can I determine the intersection between both curves? I cannot use (don't know how to) interpolation directly, since the curves are not graphs.

Let's say we have

 r[\[Phi]_] = 1 + 1/20 Sin[20 \[Phi]]; 
 tb = Table[{r[\[Phi]] Cos[\[Phi]], r[\[Phi]] Sin[\[Phi]]}, {\[Phi], 0, 2 \[Pi], 0.1}];
 ListLinePlot[tb] 

and we interpolate data stored in tb. E.g. at x = 0.95 there are 4 (or 5) different values for y. How can I plot interpolating function? I am sure I am missing something. Theoretically, I could use interpolation across segments of points on a curve but this is something I want to avoid.

Any ideas?

share|improve this question
2  
Interpolation should work. Could you post two example curves to work with? –  Szabolcs Feb 2 '13 at 18:06
    
Hi, Szabolcs. Thank you for your response. Let's say we have r[[Phi]_] = 1 + 1/20 Sin[20 [Phi]]; tb = Table[{r[[Phi]] Cos[[Phi]], r[[Phi]] Sin[[Phi]]}, {[Phi], 0, 2 [Pi], 0.1}]; ListLinePlot[tb] and we interpolate data stored in tb. E.g. at x = 0.95 there are 4 (or 5) different values for y. How can I plot interpolating function? I am sure I am missing something. –  DeeDee Feb 3 '13 at 1:50
2  
Please don't post additional information concerning your question as a comment. Please add the info to your original question by making an edit. –  m_goldberg Feb 3 '13 at 5:24
    
you mean ListPolarPlot? (there isn't any built-in function named PolarParametricPlot) –  kguler Feb 3 '13 at 12:35
1  
Generically, if two curves are given by $(x,y) = f(s)$ and $(x,y)=g(t)$, you solve $f(s)=g(t)$ for parameter values $s$, $t$. Just how to set that up in Mathematica might depend on how the particular curves $f$ and $g$ are defined. (Which is why you're being asked for more information.) You might use FindRoot or NSolve for instance. –  Michael E2 Feb 3 '13 at 15:16
show 4 more comments

migrated from stackoverflow.com Feb 2 '13 at 18:02

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 2 down vote accepted

I'm not sure that I fully understand your question.

If you interpolate the data stored in table tb, you will get a function of x instead of φ.

Maybe this could work for you:

tb2 = Table[{φ, r[φ Cos[φ], 
r[φ] Sin[φ]}, {φ, 0, 2 φ, 0.1}]; (* just added φ to the list *)
intb = Interpolation[tb2[[;;, 1 ;; 3 ;; 2]]]; (* interpolation of y[φ] *)
inta = Interpolation[tb2[[;;, 1 ;; 2]]]; (* interpolation of x[φ] *)
ParametricPlot[{inta[φ], intb[φ]}, {φ, 0, 2 π}]

Perhaps someone could provide a much more elegant solution but this one is easy and it should work!

share|improve this answer
    
@ Gregory Rut Thanks. –  DeeDee Feb 3 '13 at 21:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.