Re: Python Line Intersection

Discussion in 'Python' started by Emile van Sebille, Apr 9, 2010.

  1. On 4/9/2010 8:04 AM Peyman Askari said...
    > Hello
    >
    > This is partly Python related, although it might end up being more math related.
    >
    > I am using PyGTK (GUI builder for Python) and I need to find the intersection point for two lines. It is easy to do, even if you only have the four points describing line segments (http://www.maths.abdn.ac.uk/~igc/tch/eg1006/notes/node23.html). However, it requires that you solve for two equations. How can I do this in Python, either solve equations, or calculating intersection points some other way?


    I needed this a couple years back and used parts of pycad without much
    difficulty.

    Emile
     
    Emile van Sebille, Apr 9, 2010
    #1
    1. Advertisements

  2. Emile van Sebille

    Josh English Guest

    On Apr 9, 8:36 am, Emile van Sebille <> wrote:
    > On 4/9/2010 8:04 AM Peyman Askari said...
    >
    > > Hello

    >
    > > This is partly Python related, although it might end up being more math related.

    >
    > > I am using PyGTK (GUI builder for Python) and I need to find the intersection point for two lines. It is easy to do, even if you only have the four points describing line segments (http://www.maths.abdn.ac.uk/~igc/tch/eg1006/notes/node23.html). However, it requires that you solve for two equations. How can I do this in Python, either solve equations, or calculating intersection points some other way?

    >
    > I needed this a couple years back and used parts of pycad without much
    > difficulty.
    >
    > Emile


    You can also do this by creating a Python representation of a line. I
    did it by creating a vector class (using named tuple) and a line class
    that stored a point and a direction vector. From there, you can find
    the intersection of two lines (or a line with a circle, triangle, etc.
    through some mathematical jiggery pokery using dot products.

    If anyone want to see it I can post the code when I get home
     
    Josh English, Apr 9, 2010
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hugo
    Replies:
    10
    Views:
    1,634
    Matt Humphrey
    Oct 18, 2004
  2. SPG
    Replies:
    15
    Views:
    12,979
    ACE01
    Nov 7, 2006
  3. Replies:
    1
    Views:
    3,670
    Betty
    Apr 11, 2005
  4. Replies:
    6
    Views:
    1,313
  5. kaushikshome
    Replies:
    4
    Views:
    1,057
    kaushikshome
    Sep 10, 2006
  6. scad
    Replies:
    23
    Views:
    1,498
    Alf P. Steinbach
    May 17, 2009
  7. Chris Rebert

    Re: Python Line Intersection

    Chris Rebert, Apr 9, 2010, in forum: Python
    Replies:
    5
    Views:
    3,492
    Lie Ryan
    Apr 10, 2010
  8. Marek Stepanek
    Replies:
    12
    Views:
    704
    Peter J. Holzer
    Sep 2, 2006
Loading...