Jump to content

Group particles into four parts


Recommended Posts

Hi,

I am sorry if this is a silly question, I want to group N number of points into 4 seperate groups, suppose 30% =group1, 20% = group2, 10% = group 3, 40% = group 4. In such a way that no particle is common in any of the groups so that I can use those groups to use popwind to effect them seperately and color them seperately. Please Help.

Thanks.

Link to comment
Share on other sites

You could put the following code into a POP Wrangle to separate your particles into 4 groups.

if (@id % 10 < 3){
    @group_group1 = 1;
}

if (@id % 10 >= 3 && @id % 10 < 5){
    @group_group2 = 1;
}

if (@id % 10 >= 5 && @id % 10 < 6){
    @group_group3 = 1;
}

if (@id % 10 >= 6){
    @group_group4 = 1;
}

And then you could also replace @id by rand(@id+123) * 10 to get a random seed

  • Like 1
Link to comment
Share on other sites

10 minutes ago, celd said:

You could put the following code into a POP Wrangle to separate your particles into 4 groups.


if (@id % 10 < 3){
    @group_group1 = 1;
}

if (@id % 10 >= 3 && @id % 10 < 5){
    @group_group2 = 1;
}

if (@id % 10 >= 5 && @id % 10 < 6){
    @group_group3 = 1;
}

if (@id % 10 >= 6){
    @group_group4 = 1;
}

And then you could also replace @id by rand(@id+123) * 10 to get a random seed

Wowww!! This works perfectly. Thank you so mucccch. Please could you also explain this code a bit. Like :

if (@id % 10 < 3){
    @group_group1 = 1;
}

if (@id % 10 >= 3 && @id % 10 < 5){
    @group_group2 = 1;
}

Please explain the above part , suppose I have a 100 points. can you please explain the above part to me?

Link to comment
Share on other sites

if (@id % 10 < 3)

This divides the id number by 10 and then checks if the value after decimal point is below 3 (modulo operation), if it is, it assigns the particle into a given group.

So in practice it will do for example: 1/10 = 0.1, then it takes the 1 and compares if 1<3 and then assigns the group; or 98/10 = 9.8 where 8<3 - no group assignment.

if (@id % 10 >= 3 && @id % 10 < 5)

This does the same thing except it compares with 2 different values and returns true if both statements are correct, resulting in grouping two tenths of your points.

 

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