Jump to content

How can I find the center of cluster points?


Masoud

Recommended Posts

You could use pcfilter to easily get an approximation of the center of the cluster. Within the if statement:

vector center = pcfilter(pcloud, "P")

see: https://www.sidefx.com/docs/houdini/vex/functions/pcfilter.html

Given the function weights according to the location of the search point it would not be an exact center.

Link to comment
Share on other sites

13 minutes ago, Wooshum said:

You could use pcfilter to easily get an approximation of the center of the cluster. Within the if statement:


vector center = pcfilter(pcloud, "P")

see: https://www.sidefx.com/docs/houdini/vex/functions/pcfilter.html

Given the function weights according to the location of the search point it would not be an exact center.


I think it gives me only the position of each point.

Link to comment
Share on other sites

The pcfilter function will return the filtered (blurred, averaged, etc) positional value (or any attribute value you choose) of all of the points within the search radius and count. To demonstrate if you assign the center value to @P  and place the point wrangle within a sop solver you get a pseudo gravity sim. See attached HIP.

pseudo_gravity.hipnc

Edited by Wooshum
clarity
Link to comment
Share on other sites

Here is another approach (similar to the previous).

rough ideas:

  • use pcfind() to get clusterpoints and add polylines (for connectivity)
  • remove points which are isolated
  • get connectivity classes
  • create dummy points (one for each class), which should be the center points later
  • each point should get all cluster points as vector array attribute (using for each is possible)
  • create average over all vector array for each point to get the center

Probably there are faster solutions.

CenterOfEachColoni_01.hipnc

 

faster equivalent (avoiding for each)...

 

CenterOfEachColoni_01B.hipnc

Edited by Aizatulin
  • Like 1
Link to comment
Share on other sites

Make sure you set the same number of clusters on both the Cluster Points SOP and Cluster SOP. The Cluster Points SOP has the Cluster SOP inside it. So you could use 2 Cluster Points SOPs if you want and set the second to Average Points. You still need to set the same number of clusters on both nodes though.

-b

image.png.bbadde900ef96e08524a7fcbebd35b41.png

cluster-centers.hip

Link to comment
Share on other sites

11 hours ago, ftaswin said:

If you got the cluster from pcopen command, wouldn’t the centerpoint be @P? 
 

 

but say you have found 2 points, just say left and right, and your hero point was slightly offcentre...then the centre of the cluster should be the centre of left/right points...not the orig slightly offcentre hero.

Link to comment
Share on other sites

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