Snapping Vectors to World axis:
vector snapToAxis(vector input){
float lx = abs(input.x);
float ly = abs(input.y);
float lz = abs(input.z);
if (lx > ly && lx > lz){
return set(sign(input.x), 0, 0);
}else if(ly > lx && ly > lz){
return set(0, sign(input.y), 0);
}else{
return set(0, 0, sign(input.z));
}
}
color_correction vex:
// create spare parameters
float gamma = ch('gamma'); //default is 1
float hue = ch('hue');
float sat = ch('sat');
float val = ch('val');
@Cd = pow(hsvtorgb(rgbtohsv(@Cd) + set(hue, sat, val)), gamma);
Meassure angle between neighbour points:
// works best on unshared points
int isBorderEdge(int pt0, pt1)
{
int hedge = pointhedge(0, pt0, pt1); // try finding hedge
if (hedge == -1 )
{
hedge = pointhedge(0, pt1, pt0); // try reversed hedge
if (hedge == -1 ) return -1; // invalid hedge
}
return hedge_equivcount(0, hedge) == 1; // 1 if border edge
}
// https://forums.odforce.net/topic/25589-border-edge-query-in-vex/
int pointNeighbours[] = neighbours(0,@ptnum);
i[]@edgeNeighbours;
vector sum = {0,0,0};
foreach(int point;pointNeighbours){
sum += @P - point(0, 'P', point);
if(isBorderEdge(@ptnum,point)){
append(i[]@edgeNeighbours,point);
}
}
v@sum = sum/len(pointNeighbours );
v@prev_point_vec = normalize(@P - point(0, 'P', @edgeNeighbours[0]));
v@next_point_vec = normalize(@P - point(0, 'P', @edgeNeighbours[1]));
float difference = dot(v@sum,v@out);
if( difference > 0.5){
f@angle =degrees(acos(dot( v@prev_point_vec, v@next_point_vec)));
}else{
f@angle =360 - degrees(acos(dot( v@next_point_vec,v@prev_point_vec)));
}