[Numpy-discussion] length - sticks algorithm

Robert Kern robert.kern at gmail.com
Tue Jul 22 08:02:03 EDT 2014


What have you tried? What exactly are you having problems with? Loosely, I
would suggest the following approach:

For each stick, iterate over each stick that intersects with it (as
recorded in M). Find the coordinates of all of the intersection points.
Label the intersection points by the IDs of the two sticks that form the
intersection (normalize these IDs by keeping them in order so you don't
duplicate intersections already found; e.g. (2, 5), not (5, 2)).
Arbitrarily, but consistently, pick one end of the stick and find the
distances from that end to each of the intersection points. This induces an
order on the intersections with that stick by sorting the intersections by
their distance from the arbitrary end of the stick. You will need this to
determine which intersections on the same stick are neighbors and which
aren't. I.e., if you have 3 intersections with a given stick, (i,j), (i,k),
and (i,l), you want (i,j)-(i,k), and (i,k)-(i,l), but not (i,j)-(i,l). You
can find the distances between each of the intersections easily from that.
Use a networkx Graph to record the distances (you are making a so-called
"weighted graph").


On Tue, Jul 22, 2014 at 12:19 PM, Josè Luis Mietta <
joseluismietta at yahoo.com.ar> wrote:

>
>    Hi experts!
>
> Im working with conductivity of sticks film - systems.
>
> In my algorithm (N sticks) I have the intersection graph matrix M (M is a
> NxN matrix, M_ij=1 if sticks 'i' and 'j' do intersect, and M_ij=0 if sticks
> 'i' and 'j' do not).
> Also I have 2 lists with the end-points of each stick. In addition, I can
> calculate the intersection point (If exist) between sticks.
>
> I want to calculate all the distances between the points of intersection
> (1,2,3,...N) in the next figure:
> [image: enter image description here]
> without lose the connectivity information (which intersection is connected
> to which). In the figure, (A) is the system with sticks.
>
> I dont know how to do this. Im a python + numpy user.
>
> Waiting for your answers!
>
> Thans a lot
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>


-- 
Robert Kern
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140722/6f660155/attachment.html>


More information about the NumPy-Discussion mailing list