cgartashish Posted April 11, 2019 Share Posted April 11, 2019 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. Quote Link to comment Share on other sites More sharing options...
celd Posted April 11, 2019 Share Posted April 11, 2019 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 1 Quote Link to comment Share on other sites More sharing options...
cgartashish Posted April 11, 2019 Author Share Posted April 11, 2019 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? Quote Link to comment Share on other sites More sharing options...
celd Posted April 12, 2019 Share Posted April 12, 2019 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. Quote Link to comment Share on other sites More sharing options...
olivetty Posted April 15, 2021 Share Posted April 15, 2021 This is magic! Thanks celd for this, looks so useful! 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.