Jump to content

Is there a fast way to get the average center of a point group?


Recommended Posts

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 by magneto
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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

  • Like 1
Link to comment
Share on other sites

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 by dennis.weil
  • Like 1
Link to comment
Share on other sites

$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 by eetu
Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

@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.

  • Like 1
Link to comment
Share on other sites

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)

  • Like 3
Link to comment
Share on other sites

  • 2 years later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...