Jump to content

View more

Image of the Day

Trying out some of Pickle Jar compositions in @SketchUp and Unity, for a late #screenshotsaturday #gamedev https://t.co/HU0kZAnQtD
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net's newsletters to receive the latest updates and exclusive content.


Sign up now

sort on x and y of 2d points

2: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
2 replies to this topic

#1 giugio   Members   

246
Like
0Likes
Like

Posted 10 December 2012 - 05:36 AM

hello.
I would use a sort algorithm that works with multiple indices.
For example i would sort based on cx and cy a set of 2d point.
I think to x and y combined in a color and i wish extract the groups of 2d points that have a similar color.
Is the same thing as an ordering based on x and y?
thanks.

#2 Álvaro   Members   

20822
Like
2Likes
Like

Posted 10 December 2012 - 08:03 AM

It's unclear if you want sorting or clustering. For sorting, the algorithms don't change, but you have to provide a comparator function. The most common total order for 2D points is the lexicographical order: You first compare the x coordinates, and you only compare the y coordinates as a tiebreaker.

However, the result of sorting won't generally make a good clustering algorithm, which is what you seem to need.

#3 Bacterius   Members   

13156
Like
0Likes
Like

Posted 11 December 2012 - 12:17 PM

As Alvaro says above, you'll need to define some form of metric to compare the distance between two (x, y) "colors". The closest thing I can think of to your request is a kd-tree, which is basically a multidimensional binary tree, which sorts a list of points in k dimensions, which supports efficient nearest-neighbor search (find the N closest colors in the tree to some color, according to your definition of "closest") and range search (find all the colors in the tree closer to some color than some distance X, again according to your definition of "distance").

But it depends on what you want to do, you haven't given enough information.

Edited by Bacterius, 11 December 2012 - 12:18 PM.

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.