.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to find the intersection of a two lines.

6 REPLIES 6
Reply
Message 1 of 7
joshua.prettyman
1153 Views, 6 Replies

How to find the intersection of a two lines.

I'm trying to write a command that breaks polylines / lines along a polyline. Is there any way to

 

A. Find all intersection points of two polylines?

 

B. Break the polyline at points gained previously?

 

Any help is appreciated, but keep in mind these are polylines with 30k+ vertices... so try to tailor a response around speed if possible.

6 REPLIES 6
Message 2 of 7

yes.

You rotate both lines so one is vertical, then see if horizontal one has x values surrounding the vertical one.

Other approaches work too, but in real programs you must also deal with a really close intersection, where mayeb there is a gap of .0000001 and you wantb to consider that an intersection.

Then my approach works.

I've written this for arcs too, so anything can chop anything.

Arcs are not trivial, though you can use acad's api to cut the corner of doing your own code...

 


internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties

Message 3 of 7

Hi,

 

Did you try IntersectWith method ?

 

SomePolyLine.IntersectWith(OtherPolyline, Intersect.ExtendThis/OrNot, PointCollectionVariable, New IntPtr(0), New IntPtr(0))

 

Gaston Nunez

Message 4 of 7
Hallex
in reply to: joshua.prettyman

You can search for this issue here:

 

http://www.acadnetwork.com/board-8.0/

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 5 of 7
adadnet
in reply to: joshua.prettyman

another suggestion, you could use each poly's vertices to form a geometry curve and use those pairwise to form a curvecurveintersector object which can return intersections as doubles/points, which in turn you could use as a collection parameter in the getsplitcurves method of the original poly*. whether it's worth the trouble may to depend on how many intersections you expect, and whether it is certain that there actually is an intersection between any two polys

*i'm wary though of how reliable it is to 'carry' intersections over from geometry to database curve, so you'd have to stick to the geometry curve for the splits, which means you'd need a final conversion back into polys (if that's what you need after all)

Message 6 of 7

In the end, you must compare each segment to each segment, that does not scale well unfortunately. So you must weed out segments whose bounding box do not cross the compare sets box. Its not trivial, but has a huge speed advantage. I did this for a program that finds all closed shapes formed by any set of lines and arcs. Plines included. The box compare is a must.

internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties

Message 7 of 7

Acadnetwork.com? That is fishy, needs my email to just view posts?

internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost