Jump to content

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.

Share this post


Link to post
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

Share this post


Link to post
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?

Share this post


Link to post
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.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×