<HTML><BODY>Thanks for the answer in Stackoverflow. I checked it out.<br><br><br><br>Суббота,  4 мая 2013, 21:24 -04:00 от Warren Weckesser <warren.weckesser@gmail.com>:<br>
<blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;" class="mailru-blockquote">
        <div id="">
        



    






        

        
        
        
        
        

        



<div class="js-helper js-readmsg-msg">
        <style type="text/css"></style>
        <div id="style_13677170660000000142" class="mr_read__body">
                <base target="_self" href="https://e.mail.ru/cgi-bin/">
                
                        <div id="style_13677170660000000142_BODY">On 5/4/13, Bakhtiyor Zokhidov <<a href="sentmsg?compose&To=bakhtiyor_zokhidov@mail.ru">bakhtiyor_zokhidov@mail.ru</a>> wrote:<br>
><br>
> Hi,<br>
> I have the following code which represents intersected point of each cell in<br>
> the given two points, A(x0,y0) and B(x1,y1).<br>
><br>
> def intersected_points(x0, x1, y0, y1):<br>
> # slope<br>
> m = (y1 - y0 )/( x1 - x0)<br>
> # Boundary of the selected points<br>
> x_ceil = ceil( min (x0, x1 ))<br>
> x_floor = floor( max(x0, x1))<br>
> y_ceil = ceil( min(y0, y1))<br>
> y_floor = floor( max(y0, y1))<br>
> # calculate all intersected x coordinate<br>
> ax = []<br>
> for x in arange(x_ceil, x_floor + 1, 1):<br>
> ax.append([ x, m * ( x - x0 ) + y0 ])<br>
> # calculate all intersected y coordinate<br>
> for y in arange(y_ceil, y_floor + 1, 1):<br>
> ax.append([ ( y - y0 ) * ( 1./m ) + x0, y ])<br>
> return ax<br>
><br>
> Sample values: intersected_points(1.5,4.4,0.5,4.1)<br>
> Output: [[2.0, 1.1206896551724137], [3.0, 2.3620689655172411], [4.0,<br>
> 3.6034482758620685], [1.9027777777777779, 1.0], [2.7083333333333335, 2.0],<br>
> [3.5138888888888893, 3.0], [4.3194444444444446, 4.0]]<br>
><br>
> The output I got is unsorted values, so, for each cell coordinates, where<br>
> line crosses:<br>
> BUT, The result I want to get should be something in increased orders<br>
> like: (x0,y0), (x1,y1), (x2,y2), (x3,y3)<br>
> where x0, y0 - intial, x1,y1 - final point. Other values are intersected<br>
> line coordinates!<br>
><br>
> Any answers will be appreciated,<br>
><br>
> --  Bakhtiyor Zokhidov<br>
<br>
<br>
You also asked this question on stackoverflow<br>
(<a href="http://stackoverflow.com/questions/16377826/distance-for-each-intersected-points-of-a-line-in-increased-order-in-2d-coordina" target="_blank">http://stackoverflow.com/questions/16377826/distance-for-each-intersected-points-of-a-line-in-increased-order-in-2d-coordina</a>).<br>
 I've posted an answer there.<br>
<br>
Warren<br>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="sentmsg?compose&To=NumPy%2dDiscussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
</div>
                        
                
                <base target="_self" href="https://e.mail.ru/cgi-bin/">
        </div>

        
</div>


</div>
</blockquote>
<br></BODY></HTML>