On Apr 29, 12:41 pm, bratliff <[email protected]> wrote: > > Andrew - I like your idea of the simultaneous equations and am going > > to have a look at getting an equation set that will do this for me and > > save having to do a lot of processing of midpoints (this could get > > slow for a large number of polygons). > > For two non-parallel line segments (ab & cd) in the same plane, their > intersection "z" can be found with: > > var x0=b.x-a.x; > var x1=c.x-d.x; > var y0=b.y-a.y; > var y1=c.y-d.y; > > var z0=a.x*b.y-b.x*a.y; > var z1=d.x*c.y-c.x*d.y; > > var z={}; > > z.x=(x0*z1-x1*z0)/(x0*y1-x1*y0); > z.y=(y0*z1-y1*z0)/(x0*y1-x1*y0); > > If "z" is contained by both ab & cd, the line segments intersect. > > z.x must be between a.x and b.x > z.x must be between c.x and d.x > z.y must be between a.y and b.y > z.y must be between c.y and d.y
P.S. If either line segment crosses the international date line, you will have to make adjustments. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Maps-API?hl=en -~----------~----~----~----~------~----~------~--~---
