made a neat lil vex thing. Takes a sloppy hand-placed input curve and straightens it up for you on major axes. Doesn’t support diagonal lines yet. Has one control for maintaining segment length (as opposed to picking the closest spot to the original vertex position). Runs as a prim wrangle.
“`c int points[] = primpoints(0, @primnum); vector prev_pos = point(0, “P”, points[0]); foreach( int idx; int pt; points[1:] ){ vector this_pos = point(0, “P”, pt); vector dir = normalize(this_pos – prev_pos); float dist = distance(this_pos, prev_pos); // Determine dominant direction axis vector new_dir; vector abs_dir = abs(dir); if( abs_dir.x > abs_dir.y ){ if( abs_dir.x > abs_dir.z ) new_dir = sign(dir.x)*{1,0,0}; else new_dir = sign(dir.z)*{0,0,1}; } else { if( abs_dir.y > abs_dir.z ) new_dir = sign(dir.y)*{0,1,0}; else new_dir = sign(dir.z)*{0,0,1}; } int maintain_length = chi(“maintain_length”); vector new_pos = prev_pos + new_dir*dist; if( !maintain_length ) new_pos *= dot(dir, new_dir); setpointattrib(0, “P”, pt, new_pos); prev_pos = new_pos; }“`
finally got to use the dot product for something other than checking if two vectors point in the same direction! <:cross_gang:863101157307449365>
Attachments in this post:
http://fx-td.com/houdiniandchill/wp-content/uploads/discord/20220205/11/22/unknown.png