VEX: Delete Isolated Points

September 15, 2022

int pts[] = nearpoints(0, @P, chf(“radius”),2);if (len(pts)==1){removepoint(0,@ptnum);}

VEX: Point Pitch, Yaw, Roll

June 17, 2020

matrix3 m = maketransform(@N,@up);@orient = quaternion(m); vector4 pitch = quaternion({1,0,0}ch(‘pitch’)); vector4 yaw = quaternion({0,1,0}ch(‘yaw’));vector4 roll = quaternion({0,0,1}*ch(‘roll’)); @orient = qmultiply(@orient, pitch);@orient = qmultiply(@orient, yaw);@orient = qmultiply(@orient, roll);

VEX: Rotation Around Axis

May 19, 2020

float angle = chf(“angle”); vector4 rot = quaternion(radians(angle), {1,0,0}); @N=qrotate(rot, @N);

VEX: Phyllotaxis

May 14, 2020

int num = chi("num"); float height_ratio = chf("height_ratio"); float radius_ratio = chf("radius_ratio"); float scale_ratio = chf("scale_ratio"); float phi = radians(26.5);//(1 +sqrt(5)) / 300.0; float ang = 2 * $PI * (phi – 1) / phi; int step = chi("step"); for(int i=0; i<step; i++){ int pt = addpoint(0, set(0,0,0)); setpointattrib(0, "connect", pt, i); } for(int i=0; … Read More

VEX: Cheat Sheet

January 9, 2020

VEX Wrangle cheat sheet from John Kunz: https://mrkunz.com/blog/08_22_2018_VEX_Wrangle_Cheat_Sheet.html

VEX: Create Points at Prim Centres

January 8, 2020

int Pt_Num; @N = @N; Pt_Num = addpoint(0, @P); setpointattrib(geoself(), "N", Pt_Num, @N, "set"); removeprim(0, @primnum, 1);

VEX: split string and convert to integer

September 20, 2018

//Split @anotherAttribute based on ‘_’ string myString[] = split(s@anotherAttribute, “_”); //Use last element as attribute value s@tempString = myString[-1]; //convert string to integer i@myIntegerFromString = atoi(s@tempString);

VEX: Bend Wrangle

September 14, 2018

Taken from https://tosinakinwoye.com/2017/01/23/houdini-vex-snippets/ //Input is a line //Resample SOP on line for more points //Activate curveu attrib in resample SOP //Remap curveu to shape of bend @curveu=chramp(“ramp”,@curveu); float bamt = chf(“bend_amt”); //bend amount vector benddir = chv(“bend_dir”); //bend direction @P+= benddir * bamt * @curveu;

VEX: SOP Rotation

May 24, 2017

f@speed = fit01(rand(@ptnum), ch('minSpeed'), ch('maxSpeed')); float angle = (ch('angle')+@ptnum)*@speed; vector axis = sample_direction_uniform(rand(@ptnum*ch('seed'))); @orient = quaternion(angle, axis);