3
$\begingroup$

Here's what I have (arbitrarily sorted points):

arbitrarily sorted points

Here's what I want (Indices sorted following a circle):

Indices sorted following a circle

I would like to be able to have any number of points at any distance/angle from the center sorted as if they were part of a circle. Here's what I tried:

-a few things with convex hull, but the results seemed to be completely random every time.

-adding a mesh circle having the same number of points as the input and projecting it on the given points using geometry proximity node, but that doesn't work when the points are not distributed evenly, so many points from the circle get projected on the same point sometimes.

Here's what I think might work:

-taking one of the edges as a starting point and comparing the angles of every next edge with it, then sorting them from smallest angle to the biggest angle, and thus changing the indices accordingly. this could be done with python but I just couldn't get it to work on geometry nodes. any help will be much appreciated!

$\endgroup$
4
  • $\begingroup$ is it ok to use simulation nodes? (a branch of GN)? $\endgroup$
    – Chris
    Mar 3, 2023 at 12:29
  • $\begingroup$ not familiar with it at all, but if it gets the job done, yes why not! $\endgroup$ Mar 3, 2023 at 12:53
  • $\begingroup$ meanwhile you can check these answers: blender.stackexchange.com/questions/264857/… i am convinced it will help you $\endgroup$
    – Chris
    Mar 3, 2023 at 13:03
  • $\begingroup$ thanks! yes that answer is very useful. I kept trying it but it didn't seem to work for my case, not sure why.. $\endgroup$ Mar 3, 2023 at 13:43

2 Answers 2

5
$\begingroup$

This barely qualifies as an answer in its own right: the method is the same as @quellenform's, here The only difference in this answer, is that the sorting method is packed into a group for re-use, and the choice of weight by which to sort.

This group, given a weight, will capture the sorted indices of points on the points themselves:

enter image description here

It creates a dummy Curve Line with the same number of points as the incoming geometry, for the sole purpose of using Curve Topology's Points of Curve node, which, given weights, can return sorted indices. It transfers the weights from the incoming geometry to the curve by index, returns the sorted indices back to the incoming geometry's points (by index), and captures them.

The group can be used to sort anything on mesh points; here, clockwise viewed from positive Z, by feeding it [1- a Radial texture] as the weight:

enter image description here

Transforming the point-cluster on the left to the point-cluster on the right:

enter image description here

Point 0 could be moved around by rotating the texture, or adding to the sorted index, modulo (point-count)

$\endgroup$
5
  • $\begingroup$ absolutely brilliant!!! this works flawlessly, the idea of using a radial texture is genius, thank you! I had just solved it with good old python but this is gonna be extremely helpful to me. Thanks again! $\endgroup$ Mar 3, 2023 at 18:17
  • 1
    $\begingroup$ @AnassEzzahir np :) I wish I was a bit better at 'good ol' Python', myself . $\endgroup$
    – Robin Betts
    Mar 3, 2023 at 18:30
  • 1
    $\begingroup$ Yes, finally someone who applies my solution in a useful way! Nicely done! :D $\endgroup$
    – quellenform
    Mar 3, 2023 at 18:48
  • 1
    $\begingroup$ Hi. @quellenform No! Thanks for the method! :) GN doesn't make anything as easy to generalize as I would like.. We wind up with two steering wheels, one for left, one for right, and 4 gear-levers . I wondered whether, strictly, I should have added this as an answer to the 'duplicate' question. But maybe distinct enough. $\endgroup$
    – Robin Betts
    Mar 3, 2023 at 18:52
  • 2
    $\begingroup$ The other question is mainly about the basic techniques and possibilities, and this one (and others) is about a specific use case. Therefore, I also think that it is not a duplicate. $\endgroup$
    – quellenform
    Mar 3, 2023 at 18:59
2
$\begingroup$

In Blender 4.0.0 beta there is a new node Points to Curves by which the nice solution shown by @quellenform (see here) and which was adapted to the specific question here by @Robin Betts, can be reduced to basically this one node:

enter image description here

I'm shamelessly using the texture-based method for the sorting criteria and actually the blend file provided by @Robin Betts in his answer. Additionally a Mesh to Points node is needed and in order to convert the resulting curve back to points a Curve to Points node is used and that's all.

There is one major difference though: With the new Points to Curves nodes, points are re-indexed - e.g. what was the point with index 4 changes its index to 0 but keeps all other attributes unchanged (e.g. the point radius). With the "old" approach the points have been moved, such that the point with index 0 is moved to the position of the point which should be the first point according to the sorting criteria (and I don't see how this can be changed to a "real" re-indexing, but sometimes I miss the obvious in Geometry Nodes):

enter image description here

Adapted version of the blend file provided by @Robin Betts containing both solutions (click through the Viewers to see what is going on):

$\endgroup$
1
  • $\begingroup$ Nice way to do it. Cheers! :) $\endgroup$
    – Robin Betts
    Nov 12, 2023 at 11:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .