magneto Posted December 6, 2012 Share Posted December 6, 2012 Hi, I have a bunch of points and I want to sort their point numbers in a clockwise, or counter-clockwise order. Is there a SOP that can do this or do I have to do this manually in VOPs? Thanks Quote Link to comment Share on other sites More sharing options...
edward Posted December 6, 2012 Share Posted December 6, 2012 I'm assuming that they belong to a polygon? Try the Reverse SOP and the followed by a Sort SOP with vertex order. 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted December 6, 2012 Author Share Posted December 6, 2012 Thanks Edward, actually no it's not a polygon. It could be a polygon though Basically I want to create a polygon using the outline of multiple continuous polygons. So I was trying to create the polygon from the outline points manually. Do you think I can rely on the vertex numbers using your technique? I just thought the verte numbers wouldn't necessarily be in increasing order. So that's why I thought of creating a polygon from the points manually, but also have the points in CW or CCW order. Thanks Quote Link to comment Share on other sites More sharing options...
edward Posted December 6, 2012 Share Posted December 6, 2012 Ah, no that's a different problem. It really depends on your data, and probably hard in general without taking into account whatever structure is present. Quote Link to comment Share on other sites More sharing options...
eetu Posted December 6, 2012 Share Posted December 6, 2012 I'm not sure I understand your use case, but here's a method for just sorting points in a cw/ccw fashion. Basically just create a cylindrical uv mapping and sort according to u. For added proceduralism you could maybe make the center of the mapping be the center of bounding box or weighted average of point positions.. ee_clockwise_sort.hip 2 Quote Link to comment Share on other sites More sharing options...
magneto Posted December 6, 2012 Author Share Posted December 6, 2012 Thanks Eetu, that's exactly what I needed. Great trick 1 Quote Link to comment Share on other sites More sharing options...
acey195 Posted December 6, 2012 Share Posted December 6, 2012 Alternative you can just use a "Sort" SOP and create an expression to sort in a circle: atan2($TX,$TZ) for the XZ plane As a matter of fact, I created this a long while back already (so it may be a little inefficient). The attached OTL will only work for points, but the expression above can easily be adapted for primitives as well. Acey SortCircle.otl 4 Quote Link to comment Share on other sites More sharing options...
magneto Posted December 6, 2012 Author Share Posted December 6, 2012 Thanks alot acey, this is definitely a useful OTL. Can this be adapted to use any plane normal? This way if your points lie on an arbitrary normal like {1,2,3}.normalized(), you could still use it to sort the points in the same fashion. Thanks Quote Link to comment Share on other sites More sharing options...
acey195 Posted December 6, 2012 Share Posted December 6, 2012 Currently it only works on orthogonal planes (XY, XZ and YZ planes), I probably can make it to work on an arbitrary normal as well, but that would require a more complex expression. I haven't used that OTL in a while, since I tend to use Vopsops more nowadays, which I would also use to tackle this problem. I can try to update the OTL, using a VopSop if you want to. 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted December 6, 2012 Author Share Posted December 6, 2012 Thanks, that would be cool if you have a few free minutes, especially if it could handle any normal Quote Link to comment Share on other sites More sharing options...
acey195 Posted December 6, 2012 Share Posted December 6, 2012 It is by no means perfect, results may vary The preview Plane does not turn with negative values. I hope it works for what you are trying to do. SortCircle2.otl 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted December 6, 2012 Author Share Posted December 6, 2012 Thanks alot man, that's great Quote Link to comment Share on other sites More sharing options...
Jephyr Posted June 13, 2017 Share Posted June 13, 2017 The cylindrical mapping solution and sort by expression works wonders for me too! THANK YOU eetu! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.