How to sort points on a circle?

   12496   5   3
User Avatar
Member
228 posts
Joined: Dec. 2012
Offline
I'm having trouble sorting a group of randomly ordered points that lie on a circle. I don't care if they're ordered clockwise/counter clockwise or which point is 0 - I just need the point numbers to increase as you walk around the circle (without changing their positions).

I've tried a handful of approaches using some math (dot product, etc), but my main issue is that the sort SOP can't actually access the point number or point position in its expression fields.

Any ideas? Attached is a screen of the points I need to sort

Attachments:
pointsOnCircle.jpg (64.1 KB)

www.kmcnamara.com
User Avatar
Staff
5161 posts
Joined: July 2005
Offline
First, create a Circle from the shelf and change the type to “Polygon”. Adjust the divisions to the number of points you want. Then append a Delete SOP and delete primitive 0 (change Pattern from !* to 0) and toggle on “Keep Points”.

You should now have points sorted in a circle.
User Avatar
Member
228 posts
Joined: Dec. 2012
Offline
Hey, thanks for the reply. Unfortunately I need to keep my points exactly where they are - as you can see they are not evenly spaced and that approach would alter the position of my points. Further, since this is part of a procedural system, they may be very unevenly spaced. They will always, however, lie on a circle and I will always have the center point and radius of that circle.

Any other ideas? Thanks again for the reply
www.kmcnamara.com
User Avatar
Member
339 posts
Joined: Aug. 2007
Offline
Create a circle using the center point and radius that you have, use AttribCreate to make a float point attribute using the expression $PT/($NPT-1), AttributeTransfer this to your points and sort by expression.
Jesse Erickson
Fx Animator
WDAS
User Avatar
Member
4523 posts
Joined: Feb. 2012
Offline
If the normal of the plane your points are on is Y (XZ plane), then assuming they are already centered around the origin, you can use this expression in the Sort SOP:

atan2($TZ, $TX)
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
User Avatar
Member
228 posts
Joined: Dec. 2012
Offline
now that's the elegant solution I was looking for! Thanks Pusat

Thanks to you as well tjeeds! Looks like the atan2 solution will be more efficient

I appreciate the help
www.kmcnamara.com
  • Quick Links