Author Topic: Maximum distance between two LWPolylines  (Read 139 times)

0 Members and 1 Guest are viewing this topic.

mailmaverick

  • Bull Frog
  • Posts: 374
Maximum distance between two LWPolylines
« on: November 08, 2017, 03:45:58 am »
Hi

How to find maximum distance of any two points between two LWPolylines. Both polylines are are Zero Elevation.

One way is to break any one polyline into 100 (or more) segments (points) and then loop through the points and find the minimum distance with other polyline (using vlax-curve-getClosestPointTo), storing all values in a list and then finally taking the maximum value of all the distances.

However, this approach is largely dependent upon the number of segments. Is there any other direct way to do it ?

MickD

  • Gator
  • Posts: 2947
  • I don't need a job, I need Money!!
Re: Maximum distance between two LWPolylines
« Reply #1 on: November 08, 2017, 04:25:28 pm »
Can you post an example picture of the problem for context?

I'd probably start with the bounding boxes of both lines and see which points lie on the boundary of both boxes. You can then loop through this smaller collection of points to find the greatest distance. See below (points to use in blue circles):

"A language that doesn’t have everything is actually easier to program in than some that do."

        — Dennis M. Ritchie

MickD

  • Gator
  • Posts: 2947
  • I don't need a job, I need Money!!
Re: Maximum distance between two LWPolylines
« Reply #2 on: November 08, 2017, 04:27:14 pm »
or perhaps even one for both?

"A language that doesn’t have everything is actually easier to program in than some that do."

        — Dennis M. Ritchie

ronjonp

  • Needs a day job
  • Posts: 6398
Re: Maximum distance between two LWPolylines
« Reply #3 on: November 08, 2017, 04:39:39 pm »
Don't think that will work:

Found some info on this HERE to get furthest point from a point.
« Last Edit: November 08, 2017, 04:47:31 pm by ronjonp »

Windows 10 x64 - AutoCAD /C3D 2018

Custom Build PC

MickD

  • Gator
  • Posts: 2947
  • I don't need a job, I need Money!!
Re: Maximum distance between two LWPolylines
« Reply #4 on: November 08, 2017, 04:49:18 pm »
Don't think that will work:

Found some info on this HERE to get furthest point from a point.

Yep, good catch!
"A language that doesn’t have everything is actually easier to program in than some that do."

        — Dennis M. Ritchie