Braid from curve (VEX)

For the script to work, the curves need the vector attributes created by the Create vectors for braid (VEX) script.

With the right vector attributes in place, this setup will create a three-part braid around the curves shape. Run the script in a primitive wrangle. The script has parameters for amplitude along width and depth of the braid, frequency of the braid, and a shape ramp which multiplies the amplitudes.

int pts[] = primpoints(0,@primnum);

vector positions[];
vector pos;

for ( int i=0; i<len(pts); i++ ){
    pos = point(0,"P", pts[i]);
    append(positions,pos);
}


float amp_x = chf("amplitude_x");
float amp_z = chf("amplitude_z");


float freq_1 = chf("freq_1") * -1;
float freq_2 = 2*freq_1;

int iteration = 3;

for (int a=0; a<iteration; a++) {
 
    int prim = addprim(0,"polyline");
    
    for ( int i=0; i<len(pts); i++ ){
    
        vector og_pos = positions[i];
        vector tangentv = point(0,"tangentv",pts[i]);
        vector cross = point(0,"cross",pts[i]);
        float curveid = i;
        
        float curveu = point(0,"curveu",pts[i]);
        curveu = chramp("shape_ramp",curveu);
        
        if ( a==0 ){
        
            pos = og_pos + sin(curveid*freq_1) * amp_x * cross * curveu;
            pos = pos + sin(curveid*freq_2) * amp_z * tangentv * curveu;
            
        }
        
        
        if ( a==1 ){
        
            float period = 2*PI/abs(freq_1);
            float offset = period/3;

            pos = og_pos + sin((curveid+offset)*freq_1) * amp_x * cross * curveu;
            pos = pos + sin((curveid+offset)*freq_2) * amp_z * tangentv * curveu;
            
        }
        
        if ( a==2 ){
        
            float period = 2*PI/abs(freq_1);
            float offset = period/(3*2);

            pos = og_pos + sin((curveid+offset)*freq_1) * amp_x * cross * curveu * -1;
            pos = pos + sin((curveid+offset)*freq_2) * amp_z * tangentv * curveu;
            
        }
        
        vector newpos = pos;
        int pnt = addpoint(0,newpos);
        addvertex(0,prim,pnt);
    }
}

removeprim(0,@primnum,1); //remove original primitive
Previous
Previous

Procedural Cornrows Study

Next
Next

Multiply curve (VEX)