TheSwamp

Code Red => .NET => Topic started by: earthsnake on February 08, 2019, 09:57:35 PM

Title: Hello, and Point3dCollection Question
Post by: earthsnake on February 08, 2019, 09:57:35 PM
Hi Everyone, I'm Ophion. I'm hoping you can help me.

Anyone know a more efficient way to find the closest point in a Point3dCollection from a coordinate other than iterating through every one of them using a distanceto check?

Thanks!
Title: Re: Hello, and Point3dCollection Question
Post by: nullptr on February 08, 2019, 10:36:02 PM
Welcome to the club Ophion,

That's a fun topic, one that has been asked a few times on this forum, I would invite you to search "closest point" using the search feature
as you might find exactly what you need, or a place to start.

Cheers
Title: Re: Hello, and Point3dCollection Question
Post by: gile on February 09, 2019, 02:26:41 AM
Hi,

As far as I know, the Point3dCollection is a resizable indexed data structure similar to List<Point3d>, so it doesn't provided any other search way than iterating the whole collection.
If you have several searches to do in the same big point collection, you can convert the Point3dCollection into a more efficient data structure (this supposes the Point3dcollection to be completely iterated one time for the conversion.
Some times ago, I tried to implement a Point3dTree structure base on a kd-tree (https://en.wikipedia.org/wiki/K-d_tree).
The discussion sarts here (http://www.theswamp.org/index.php?topic=44312.0) and the last improved version here (http://www.theswamp.org/index.php?topic=44312.msg496481#msg496481).
The Point3dTree class provides a NearestNeighbour() method which returns the closest point.