[SciPy-User] How to find the intersections between two lines

seasoul bioseasoul@gmail....
Thu Apr 8 23:15:37 CDT 2010

This is my first post in the mailing list.
I want to find the intersections between two lines. One line is an arbitrary
straight line, the other is a fitting line created by a interpolation
Below is a simple code:

x = linspace(0,10,20)
y = rand(20)*10
f = interpolate.interp1d(x,y,kind=5)
xx = linspace(0,10,100)
yy = f(xx)
y2 = x
def func(x):
   out = [x[1]-x[0]]
   return out

The fitting line is a polynomial curve, the straight line is y=x. This
function can only find one of the intersection points,not all.

I tried to use x[:,1] and x[:,2], and hope in the function func, the
operation is element-by-element, but some errors came out.
Any help is appreciated.

The output figure:

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20100409/c28e748a/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 4.png
Type: image/png
Size: 33435 bytes
Desc: not available
Url : http://mail.scipy.org/pipermail/scipy-user/attachments/20100409/c28e748a/attachment-0001.png 

More information about the SciPy-User mailing list