Functions
Match a name to point id
Port 1: Voronoi fracture with named primites Port 2: Found centroid of each voronoi cell -> each centroid has a distance attribute Transfer the centroid attribute to each named primitive points
// run over primitivesstring piece_name = s@name;
//findattribval(1, "point", "name", piece_name,int anc_ptnum = nametopoint(1, piece_name);if (anc_ptnum == -1) return;
float dist = point(1, "dist", anc_ptnum);f@dist = dist;
Source file: monolith
I was using findattrival BUT: The most common use cases (finding an point/primitive by its name or id attribute) have easier-to-use dedicated wrapper functions: nametopoint, nametoprim, idtopoint, and idtoprim. (vex reference)
Set attribute metadata type info
VEX reference : Attribute type metadata
setattribtypeinfo
To equirectangular
Not the same as using ‘topolar’ and ‘frompolar’ in a VOP
//to spherical firstfloat theta = atan2(@P.z, @P.x);float phi = acos(@P.y);float rho = length(@P); // if radius == 1 then rho = 1
//rad to degfloat long = degrees(theta);float lat = degrees(phi);
//fitfloat x = fit(long, -180.0, 180, 0, 1);float z = fit(lat, 0, 180, 0, 1);
// x by 2@P = set(x*2, 0, z);
From cartesian to spherical and back
//to spherical//sphere of radius 1
float theta = atan2(@P.z, @P.x);float phi = acos(@P.y);//float rho = length(@P); // rad == 1float rho = 1;
//to cartesian
float x = rho * sin(phi) * cos(theta);float z = rho * sin(phi) * sin (theta);float y = rho * cos (phi);
@P = set(x, y, z);