magneto Posted June 19, 2012 Share Posted June 19, 2012 (edited) At the geometry level, is there a fast way to get the average center of a point group? Maybe some expression? Or do I have to write a python sop for this and output it to a detail attribute? Also the points are not necessarily connected to polygons. Thanks Edited June 19, 2012 by magneto Quote Link to comment Share on other sites More sharing options...
gaurav Posted June 19, 2012 Share Posted June 19, 2012 At the geometry level, is there a fast way to get the average center of a point group? Maybe some expression? Or do I have to write a python sop for this and output it to a detail attribute? Also the points are not necessarily connected to polygons. Thanks May be Edit sop. Choose group and type, look at the pivot value. Quote Link to comment Share on other sites More sharing options...
magneto Posted June 19, 2012 Author Share Posted June 19, 2012 I tried it, but when I refer to its value, it's 0,0,0, so it only makes sense on Edit SOP's context I think. Also I need the actual average point center where it might not always be at the same location as the bounding box center, but those ideas are welcome too Quote Link to comment Share on other sites More sharing options...
gaurav Posted June 19, 2012 Share Posted June 19, 2012 I tried it, but when I refer to its value, it's 0,0,0, so it only makes sense on Edit SOP's context I think. if you append edit sop in viewport after selecting the group it shd update the pivot location. But true not really the point center. Quote Link to comment Share on other sites More sharing options...
magneto Posted June 19, 2012 Author Share Posted June 19, 2012 Thanks, I see what you mean. Although another problem with that approach is since I need this to be done automatically inside a digital asset, I don't think I could get the Edit SOP to update its pivot. But still neat trick Quote Link to comment Share on other sites More sharing options...
dennis.albus Posted June 19, 2012 Share Posted June 19, 2012 There are actually several ways to do this. You obviously can't simply use $CEX or the centroid expression, because as you said this would just give you the center of the bounding box. I've attached a file with two possibilities to get the average position of a pointcloud. The first possibility is to average the points with a fuse sop. The second creates a new primitive with an add sop and sources a particle at the primitive center. -dennis center.hip 1 Quote Link to comment Share on other sites More sharing options...
eetu Posted June 19, 2012 Share Posted June 19, 2012 How about AttribPromote P to a detail attrib with the "average" method? For some reason it doesn't seem to want to promote P as it is, you need to make a copy of P and promote that.. ee_pointaverage.hip 1 Quote Link to comment Share on other sites More sharing options...
dennis.albus Posted June 19, 2012 Share Posted June 19, 2012 (edited) I've added two other possibilities that are both using the rivet object as an intermediate step. One is using the origin function which is rather slow if you want to use it extensively. It also has some problems with updating correctly if you have a moving point cloud. The fourth possibility just merges the center point of the rivet object back into sops and reads its position. -dennis center.hip Edited June 19, 2012 by dennis.weil 1 Quote Link to comment Share on other sites More sharing options...
dbukovec Posted June 19, 2012 Share Posted June 19, 2012 $GCX $GCY $GCZ (group centroid) in a foreach and an add sop? 1 Quote Link to comment Share on other sites More sharing options...
eetu Posted June 19, 2012 Share Posted June 19, 2012 (edited) $GCX $GCY $GCZ (group centroid) in a foreach and an add sop? Isn't centroid the center of the bounding box, not the average point position? Also I need the actual average point center where it might not always be at the same location as the bounding box center Once again nice to see in how many ways one can approach a problem Edited June 19, 2012 by eetu Quote Link to comment Share on other sites More sharing options...
magneto Posted June 19, 2012 Author Share Posted June 19, 2012 Thanks alot guys, many useful solutions. @Eetu: your solution seems pretty elegant, using attribute promote. But I have a few questions. The scatter sop is your initial state for the points, right? I am just not sure why you added font and a torus but only used the font? Also what's the point of delete sop? If my object was like that in the scatter1, then using attribute create and then promote is all I need to do, right? Lastly where can I use $GCX $GCY $GCZ? Is it available at the sop level of any sop that supports groups? Like can it be used inside an attribcreate with detail type? I will try that too even though it's not really average point center. Thanks all Quote Link to comment Share on other sites More sharing options...
eetu Posted June 19, 2012 Share Posted June 19, 2012 @Eetu: your solution seems pretty elegant, using attribute promote. But I have a few questions. The scatter sop is your initial state for the points, right? I am just not sure why you added font and a torus but only used the font? Also what's the point of delete sop? If my object was like that in the scatter1, then using attribute create and then promote is all I need to do, right? 1) I used font+scatter to get many non-symmetrical point clouds. The torus is there just to have something else, to be able to show where to select which group you want to use. 2) I wanted to copy the box just to the one newly created point, for visualization purposes. 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted June 19, 2012 Author Share Posted June 19, 2012 Thanks eetu, now I understand Quote Link to comment Share on other sites More sharing options...
johnm Posted June 19, 2012 Share Posted June 19, 2012 have you tried the 'pointavg' expression? depending on where & how you want to evaluate it, the X average would be: pointavg("../scatter1", "P", 0) the Y average: pointavg("../scatter1", "P", 1) and Z: pointavg("../scatter1", "P", 2) 3 Quote Link to comment Share on other sites More sharing options...
magneto Posted June 19, 2012 Author Share Posted June 19, 2012 Thanks John, that looks like another amazing way to do it. I will try it today and report Quote Link to comment Share on other sites More sharing options...
s4l4x Posted April 12, 2015 Share Posted April 12, 2015 (edited) Thanks John! So easy!!! pointavg("../scatter1", "P", 0) pointavg("../scatter1", "P", 1) pointavg("../scatter1", "P", 2) Edited April 12, 2015 by s4l4x Quote Link to comment Share on other sites More sharing options...
s4l4x Posted April 14, 2015 Share Posted April 14, 2015 Or get the point average of the current node using opinput: pointavg("../"+opinput(".",0), "P", 0) pointavg("../"+opinput(".",0), "P", 1) pointavg("../"+opinput(".",0), "P", 2) 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.