[SciPy-User] [SciPy-user] How to find the intersections between two lines
Fri Apr 9 02:23:03 CDT 2010
A nice idea. Thank you Charles. I will give it a try.
Charles R Harris wrote:
> On Thu, Apr 8, 2010 at 10:15 PM, seasoul <firstname.lastname@example.org> wrote:
>> 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 procedure.
>> 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-x]
>> 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.
> This is spline interpolation, not polynomial. So I think you are stuck
> sampling the difference of the two curves on a grid, finding adjacent
> of sample points at which the function has opposite sign, and then calling
> one of the 1d zero finders, brentq for instance.
> SciPy-User mailing list
View this message in context: http://old.nabble.com/How-to-find-the-intersections-between-two-lines-tp28187442p28188548.html
Sent from the Scipy-User mailing list archive at Nabble.com.
More information about the SciPy-User