Search the Community
Showing results for tags 'arrays'.
-
Hi everyone ! I'm struggling with a little problem. What I have, is a point cloud with an attribute integer "clumpid" (visualized just below). What I want to do, is, for each of the @clumpid values (@clumpid values are from 0 to 5) create an array containing all the points that have the same @clumpid values. For example, for the points that have the @clumpid value at 3, I want to have an array called for instance " i[]@array_3" containing all the points that have the @clumpid value at 3. If possible, I don't want to use the "foreach loop" SOPs. I tried a few things but the closest solution I have is this one: But unfortunately, all the arrays are empty.. Thank you in advance for your replies !!
-
How can I shift values in an array using a for loop? For example: [0,0,0,1,1,1]->[1,0,0,0,1,1] I would think that this code would work but it does not. Any help would be appreciated. for(int j = 0; j < 6; j++ ){ if(@new_tile_array[@new_prim_id] == 1){ break; } else{ int popped = pop(@new_tile_array); append(@new_tile_array,popped); } }
-
Harder, Better, Faster, Stronger please! Looking for some voodoo to optimize these snippets... Find Unique Elements in One Array function int[] unique_elements (int arr[]) { int _arr[] = sort(arr); for (int i=0; i<len(_arr); i++) { while(_arr[i] == _arr[i+1]) pop(_arr,i); } return _arr; } Get Duped Elements in One Array function int[] duped_elements (int arr[]) { int _arr[] = sort(arr); int result[] = {}; int dupe; for (int i=0; i<len(_arr); i++) { while(_arr[i] == _arr[i+1]) { dupe = pop(_arr,i); } append(result, dupe); } return result; } Find Common Elements in Two Arrays function int[] common_elements (int arr1[]; int arr2[]) { int result[]; foreach (int i; unique_elements(arr1)) { foreach (int j; unique_elements(arr2)) { if (i==j) push(result,j); } } return result; } Find Different Elements in Two Arrays function int[] different_elements (int arr1[]; int arr2[]) { int result[]; int _arr1[] = unique_elements(arr1); int _arr2[] = unique_elements(arr2); foreach(int i; _arr1) { if(find(_arr2,i)<0) append(result,i); } foreach(int j; _arr2) { if(find(_arr1,j)<0) append(result,j); } return result; } Swap Arrays function int[] swap (int arr1[]; int arr2[]) { int temp[] = arr1; arr1 = arr2; arr2 = temp; return {1}; } Here's some of what I was using to test it... these are all based on arrays of integers but could be tweaked obviously for other types. i[]@arr1 = {3, 2, 15, 27, 1, 3}; i[]@arr2 = {3, 2, 3, 15, 41, 41, 1, 2, 2}; i[]@arr_comm = common_elements (@arr1, @arr2); i[]@arr_diff = different_elements (@arr1, @arr2); i[]@arr_uniq = unique_elements (@arr1); i[]@arr_dupe = duped_elements (@arr2);
-
Hi Everyone I'm currently trying to create circular point groups, inside a voronoi fracture. My outputs are groups currently are primitives but when I conver them to points, i have to many clustered together. I'm thinking of a solution by either getting the max/min two points of each primitive inside my group and delete the other points from the group. Unfortunately my VEX skills are very limited, I seem to be declaring my max function wrong. If someone could help me figure it out that would be great, also an explanation to why my attempt didn't work/ any other solutions towards achieving the same result would be more than welcome. Cheers Example.hipnc and for any questions im trying to make a tool that creates ground slams, as you can see there's distinct circular fractures which im trying to replicate, but also make procedural.
-
Hi, If I use an attribute wrangle to create an array attribute and populate the array like so: i[]@stuff = nearpoints (0, @ape, 1, 23); I can then slice the array like so: i@branch = @stuff[3]; and all is good in the world. However, if I attach another wrangle node and try to use the same slice, I get an error even though the array attribute shows up in the spreadsheet? Not a showstopper but I'd love to know why the attribute isn't accessible.