# [Numpy-discussion] "Lists" and "Join" function needed

Bakhtiyor Zokhidov bakhtiyor_zokhidov at mail.ru
Sun May 5 07:39:28 EDT 2013

``` Thanks for the answer in Stackoverflow. I checked it out.

Суббота,  4 мая 2013, 21:24 -04:00 от Warren Weckesser <warren.weckesser at gmail.com>:
>On 5/4/13, Bakhtiyor Zokhidov < bakhtiyor_zokhidov at mail.ru > wrote:
>>
>> Hi,
>> I have the following code which represents intersected point of each cell in
>> the given two points, A(x0,y0) and B(x1,y1).
>>
>> def intersected_points(x0, x1, y0, y1):
>> # slope
>> m = (y1 - y0 )/( x1 - x0)
>> # Boundary of the selected points
>> x_ceil = ceil( min (x0, x1 ))
>> x_floor = floor( max(x0, x1))
>> y_ceil = ceil( min(y0, y1))
>> y_floor = floor( max(y0, y1))
>> # calculate all intersected x coordinate
>> ax = []
>> for x in arange(x_ceil, x_floor + 1, 1):
>> ax.append([ x, m * ( x - x0 ) + y0 ])
>> # calculate all intersected y coordinate
>> for y in arange(y_ceil, y_floor + 1, 1):
>> ax.append([ ( y - y0 ) * ( 1./m ) + x0, y ])
>> return ax
>>
>> Sample values: intersected_points(1.5,4.4,0.5,4.1)
>> Output: [[2.0, 1.1206896551724137], [3.0, 2.3620689655172411], [4.0,
>> 3.6034482758620685], [1.9027777777777779, 1.0], [2.7083333333333335, 2.0],
>> [3.5138888888888893, 3.0], [4.3194444444444446, 4.0]]
>>
>> The output I got is unsorted values, so, for each cell coordinates, where
>> line crosses:
>> BUT, The result I want to get should be something in increased orders
>> like: (x0,y0), (x1,y1), (x2,y2), (x3,y3)
>> where x0, y0 - intial, x1,y1 - final point. Other values are intersected
>> line coordinates!
>>
>> Any answers will be appreciated,
>>
>> --  Bakhtiyor Zokhidov
>
>
>You also asked this question on stackoverflow
>( http://stackoverflow.com/questions/16377826/distance-for-each-intersected-points-of-a-line-in-increased-order-in-2d-coordina ).
> I've posted an answer there.
>
>Warren
>_______________________________________________
>NumPy-Discussion mailing list
>NumPy-Discussion at scipy.org
>http://mail.scipy.org/mailman/listinfo/numpy-discussion

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20130505/a7ef9ed1/attachment.html>
```