yLib

camdir

vector pt0 = point(1,'P',0);
v@raydir = normalize(  pt0 - @P )*-1;

circuit

//primpoint
int primPts [] = primpoints(0,@primnum);
//calculer dir
vector pt1 = point(0,"P",primPts[1]);
vector pt0 = point(0,"P",primPts[0]);
setpointattrib(0,"name",primPts[1],"corner","set");
setpointattrib(0,"name",primPts[0],"corner","set");
//dirPoint
vector ptPos = lerp(pt1,pt0,0.5);
int dirPt = addpoint(0,ptPos);
vector dir = ptPos*-1 ;
setpointattrib(0,"dir",dirPt,dir,"set");
setpointattrib(0,"name",dirPt,"midPoint","set");
//addPoints sur curve
int maxPt = chi("maxPt");
int seed = chi("seed")+@primnum;
//boucle
for (int i=0;i<=maxPt;i++){
    float randNumber = rand(i+seed);
    vector ptCurve = lerp(pt1,pt0,randNumber);
    addpoint(0,ptCurve);
}
//remove dirPt
//removepoint(0,dirPt);

connectAdjEdgePropagationChaos

// connect adjacent edge style propagation plus chaos
//depart = 0
// it = $F
int depart = chi("depart");
vector color = set(0,1,0);
int voisins[] = neighbours(0,depart);
int maxIt = fit(chi("it"),0,30,0,30);
int prim = addprim(0,"polyline");

for (int i;i<maxIt;i++){

    foreach (int voisin;voisins)
        {
        setpointattrib(0,"Cd",voisin,color,"set");
        addvertex(0,prim,voisin);
        int newArray[]=neighbours(0,voisin);
        append(voisins,newArray);

        }

        foreach(int i ; voisins)
            {
                foreach(int index ;int b ; voisins)
                {
                    if (b==i){removeindex(voisins,index);}
                }
            } 
}

connectAjacentEdge

// connect adjacent edge style marche de saoul
//depart = 0
// it = $F
int voisin(int depart;int direction){
    int voisin = neighbour(0,depart,direction);
    vector color = set(0,1,0);
    int prim = addprim(0,"polyline");
    addvertex(0,prim,depart);
    addvertex(0,prim,voisin);
    setpointattrib(0,"Cd",voisin,color,"set");
    return voisin;
}

int depart = chi("depart");
int direction = 2;
int max = chi("max");

for (int i ; i<max;i++){
    direction = floor(rand(i)*3);
    depart = voisin(depart,direction);
}

contactSheet

int x=0;
int y=2;
vector pos;
int ligne = chi("ligne");
int max = @numpt;
for (int i = 0; i<max;i++){
    x+=2;
    if (i%ligne == 0){
        y+=-2;
        x=0;
        }
    pos = set(x,y,0);
    setpointattrib(0,"P",i,pos,"set");

}

delByCamFrustrum

vector ndc=toNDC(chs("camPath"),@P);
//@Cd = ndc; // viz
float secu = 0.1;
if(ndc.x+secu<0||ndc.x-secu>1||ndc.y+secu<0||ndc.y-secu>ch("seuil")||ndc.z>0){
removepoint(geoself(),@ptnum);
}

delPointByProximity

int numPoint = chi("numPoint");

int mypc = pcopen(0,"P",@P,chf("radius"),numPoint);

@Cd= chramp("ramp",fit(pcnumfound(mypc),0,numPoint,0,1));

if (@Cd.x<chf("seuilColor"))removepoint(0,@ptnum);

dyn_menu

geo=hou.node("./IN_shapes").geometry()

menuList=[]

for point in geo.iterPoints():
    name=point.attribValue("name")
    if not name in menuList:
        menuList.append(name)
        menuList.append(name)

return menuList

fillpointBetweenPoint


float searchrad=ch("searchrad");
float mindist=ch("mindist");
int maxpoints=chi("maxpoints");
int fillpoints=chi("fillpts");

vector clpos;
int handle=pcopen(0,"P",@P,searchrad,maxpoints+1);
int i=0;
while(pciterate(handle))
{
    if (i==0) // the first point found should be the closest, in this case, itself. We want to skip it.
    {
        i++;
        continue;
    }
    pcimport(handle,"P",clpos);
    if (length(@P-clpos)>mindist)
    {
        vector pointstep=(clpos-@P)/(fillpoints*2+1); // this ensures there are no duplicate point
                                                     // at the cost of doubling the fill points number
        for (int t=0;t<fillpoints;t++)
            addpoint(0,@P+(pointstep*float(t+1)));
    }
}

intersectRay

vector orig = point(1,"P",0);
float dist = distance(orig,@P)-0.01;
vector dir = normalize(@P-orig)*dist;

vector pos,uvw;
int intersect = intersect(0,orig,dir,pos,uvw);

if (intersect>0 ){
@Cd = 0;
}

keepXpts

float val = rand(@id + ch("seed"));
int npts = npoints(0);
if(val * npts > chi("max_pts")) removepoint(0,@ptnum);

nameList

// creer une liste a partir des noms sur les points 

s[]@nameListe;
string nameT;
int maxit=@numpt;
for (int i=0;i<maxit;i++)
{
    nameT = point(0,"name",i);
    if (len(nameT)>0 && find(s[]@nameListe,nameT)<0){
        push(s[]@nameListe,nameT);}
}

nearpointConnect

// input un geo test input deux nuage de pts
int handle = pcopen(1,"P",@P,20,100);
int max =  pcnumfound(handle);

for (int i;i<max;i++){
vector start = point(1,"P",i);

int near[]= nearpoints(0,start,10,3);

int prim = addprim(0,"polyline");
int startPt = addpoint(0,start);

int primTwo = addprim(0,"poly");

foreach(int index;int pt;near){
    vector color = rand(index);
    setpointattrib(0,"Cd",pt,color,"set");
    addvertex(0,prim,startPt);
    addvertex(0,prim,pt);
    addvertex(0,primTwo,pt);
}
}

phylotaxis

//phylotaxis
int count = chi("res");
float bound = 10.0;
float tau = 6.28318530; // 2*$PI
float phi = (1+ sqrt(5))/2; // Golden ratio = 1.618
float golden_angle = (2 - phi)*tau; // In radians(*tau)
vector pos = {0,0,0};
float radius = 1.0;
float theta = 0;
int pt;
vector polar_to_cartesian(float theta; float radius)
{ 
return set(cos(theta)*radius, 0, sin(theta)*radius);
}
for (int n=0; n<count; n++){ 
radius = bound * pow(float(n)/float(count), ch('power')); 
theta += golden_angle; 
pos = polar_to_cartesian(theta, radius); 
// Create UP, pscale and N attr 
pt = addpoint(0, pos); 
setpointattrib(0, "pscale", pt, pow(radius,0.5)); 
setpointattrib(0, "N", pt, normalize(-pos)); 
setpointattrib(0, "up", pt, set(0,1,0));
}

pointDeform

int prim;
vector uv;
xyzdist(1,@P,prim,uv);
@P= primuv(2,"P",prim,uv);

pyramideGrid

//grille de pyramides
vector pyramide (vector start;int index){
//base
vector pos0 = set(0,0,0)+start;
vector pos1 = set(2,0,0)+start;
vector pos2 = set(2,0,2)+start;
vector pos3 = set(0,0,2)+start;
//addpoint pyramide
int p0 = addpoint(0,pos0);
int p1 = addpoint(0,pos1);
int p2 = addpoint(0,pos2);
int p3 = addpoint(0,pos3);
//prim
int base = addprim(0,"poly",p0,p1,p2,p3);
//top
vector pos4 = set(1,2,1)+start;
int p4 = addpoint(0,pos4);
//prim
int poly1 = addprim(0,"poly",p0,p1,p4);
int poly2 = addprim(0,"poly",p1,p2,p4);
int poly3 = addprim(0,"poly",p2,p3,p4);
int poly4 = addprim(0,"poly",p3,p0,p4);
//out 
vector array[]= array(pos1,pos4); 
vector out = array[index];
return out;
}

vector start = 0;
vector sideStart =0;

for (int i;i<5;i++)
{
    if (i!=0){
    start = pyramide(start,1);
    sideStart = start;}

    for (int i;i<7;i++)
        {
        sideStart = pyramide(sideStart,0);
        }
}

randId

int maxPoint,inc,randInt,maxPts,myArray[];
float seed;

seed = ch("seed");
maxPts = npoints(0);
inc = 0;
randInt= floor(rand(seed)*maxPts);

for (int i=0; i<maxPts;i++){

    while (len(myArray)<maxPts){
        if (find(myArray,randInt)<0){ 
        append(myArray,randInt);
        }
        else {randInt = floor(rand(inc+seed)*maxPts);
        }
    inc++;
    }
}

i@idRand = myArray[@ptnum];

maxPoint = chi("maxPoint");
if (@idRand>maxPoint)removepoint(0,@ptnum);

scatterBox

vector min,max;
int it = 0;
getbbox(0,min,max);
int maxIt = chi("maxIt");

while (it<=maxIt){
it++;
float randx = rand(it+987)*max.x;
float randy=rand(it+876)*max.y;
float randz=rand(it)*max.z;
vector rand = set(randx,randy,randz);
addpoint(0,rand);
}

transformToOrigin

vector basePtPos = point (0,"P",chi("basepoint")); 

matrix m = ident();

v@Z_axis =normalize( basePtPos - point(0,"P",neighbour(0,chi("basepoint"),1)));
v@Y_axis =normalize( cross(@Z_axis,basePtPos-point(0,"P",neighbour(0,chi("basepoint"),0))))*-1;
v@X_axis =normalize ( cross (@Z_axis,@Y_axis))*-1 ;

m*= set (@X_axis,@Y_axis,@Z_axis);
translate (m,basePtPos);
// invert transform 
4@myMatrix = m;
m=invert(m);

@P*= m;

// revert transform 

//4@Um = point (1,"myMatrix",0);
//@P*= @Um ;

transformToOriginInvert

4@Um = point (1,"myMatrix",0);
@P*= @Um ;

triggerAction

twistVolume

//twist volume dans un vol wrangle
float angle = radians(ch("angle"))*relbbox(0,@P).y*(length(@P*set(1,0,1))*0.6);
vector axis = set(0,1,0);
vector newPos = qrotate(quaternion(angle,axis),@P);
@density = volumesample(0,0,newPos);

udim

// <UDIM> variable udim pour les texture

vector uv = primuv(0, "uv", @primnum, set(0.5, 0.5, 0));
i@udim = 1001 + int(uv.x) + int(uv.y)*10;

volumeCollision


//input 0 geo
//input 1 sdf fill interior large voxel band
vector displace,gradient,vSample;

vSample= volumesample(1,"surface",@P);
gradient = volumegradient(1,"surface",@P);

displace = abs(vSample)*gradient;

if (vSample<0){
@P+=displace;
}
else {
@P+=(displace*-1);
}

yScatter

@group_prim = 1;
int maxpt = chi("max");
vector randPos, randUv,tempN,tempUV;
int randPrim;
int seed = chi("seed");

for (int i=0; i<maxpt; i++) {
    randPrim = int(rint(rand(i+seed*1000)*@numprim));
    randUv = set(rand(i+5),rand(i+8),0);
    randPos = primuv(0,"P",randPrim,randUv);
    //transfer att
    tempN =primuv(0,"N",randPrim,randUv);
    tempUV=primuv(0,"uv",randPrim,randUv);
    //add pts
    int nPt = addpoint(0,randPos);
    //set att
    setpointattrib(0,"N",nPt,tempN,"set");
    setpointattrib(0,"uv",nPt,tempUV,"set");
}

if (@group_prim==1)removeprim(0,@primnum,1);
VEX