Random
Random distribution
-
Add to each point random points in a circle
vex vector points[]; // not really necessaryfor (int i = 0; i < chi("pnum"); i++){vector2 v2 = rand(@P.x + i, @P.z + i);vector2 in_circle = sample_circle_uniform(v2);in_circle *= 0.2;vector in_circle_v3 = set(in_circle.x + @P.x, @P.y, in_circle.y + @P.z);push(points, in_circle_v3); // ummaddpoint(0, in_circle_v3);} -
Add points around a point and align to normal
vex vector normal = normalize(@P);vector up = {0,1,0};matrix3 m = maketransform(normal, up);vector4 orient = quaternion(m);for (int i = 0; i < chi("pnum"); i++){vector2 v2 = rand(@P.x + i, @P.z + i);vector2 in_circle = sample_circle_uniform(v2);in_circle *= chf("range");//The points aligned to the z axis, and up as 0,1,0vector in_circle_v3 = set(in_circle.x, in_circle.y, 0); // Importantin_circle_v3 = qrotate(orient, in_circle_v3);in_circle_v3 += @P;addpoint(0, in_circle_v3);}
Random int from number of points
// Detail modeint numPts = npoints(0);float randValue = rand(numPts + @Frame);float fitFloat = fit(randValue, 0, 1, 0, poolNumPts -1);int indexSelection = int(fitFloat);
Random samples in cone direction
// run over one point, from add_point SOPfloat dist_m = chf("distance");float angle_d = chf("angle_deg");float inrshell = chf("inner_shell_dist");int seed = @ptnum + chi("seed");
vector dir = {0,1,0};vector rand_len = random(@ptnum);
vector sample_p = sample_direction_cone( dir, radians(angle_d), rand(seed));
float low = fit01(rand_len.x, inrshell, 1.0);sample_p *= low;
@P = sample_p * dist_m;