.NET

.NET

Reply
Contributor
18 Posts
0 Kudos
Registered: ‎07-17-2012
Post 1 of 2

How to detect a nearest co-ordinate from an array of co-ordinates ?

116 Views, 1 Replies
07-18-2013 11:59 PM

Hi all,

 

I have an array of co-ordinates (List A) from a polyline. I have one of the co-ordinate (B) from a polyline which is located around the array of co-ordinates of the other polyline (List  A).

 

I want to detect the co-ordinate in List A which is closest to co-ordinate (B).

 

Known co-ordinates would be, 

1. Array of co-ordinates

2. the reference co-ordinate.

Can anyone help ?

 

 

Valued Contributor
75 Posts
6 Kudos
Registered: ‎12-03-2003
Post 2 of 2

Re: How to detect a nearest co-ordinate from an array of co-ordinates ?

07-19-2013 05:25 AM in reply to: CodeBug

If what wou need is to get the nearest vertex, you could loop through all vertex and get the lowest value of:

 

        Math.Pow(vertex.X - coordinate.X, 2) + Math.Pow(vertex.Y - coordinate.Y, 2)

 

The lowest value indicates the nearest vertex.

 

 

 

But if you need the nearest point to the polyline, you could use the "GetClosestPointTo" method of the polyline.

Luis Alberto Manero, Geograma.com
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post