Python Line Intersection
Josh English
joshua.r.english at gmail.com
Fri Apr 9 19:39:36 CEST 2010
On Apr 9, 8:36 am, Emile van Sebille <em... at fenx.com> 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
More information about the Python-list
mailing list