utils: added circular shaping functions from flong (Equation of a Circle From 3 Points and Joining Two Lines with a Circular Arc Fillet still missing)
This commit is contained in:
@@ -265,3 +265,53 @@ float cubic_bezier_through(float x, vec2 a, vec2 b) {
|
|||||||
return clamp(y, 0., 1.);
|
return clamp(y, 0., 1.);
|
||||||
}
|
}
|
||||||
// cubic bezier through points end
|
// cubic bezier through points end
|
||||||
|
|
||||||
|
// Circular shaping
|
||||||
|
|
||||||
|
float circ_ease_in (float x){
|
||||||
|
return 1. - sqrt(1. - x*x);
|
||||||
|
}
|
||||||
|
|
||||||
|
float circ_ease_out (float x){
|
||||||
|
return sqrt(1. - pow(1. - x, 2.));
|
||||||
|
}
|
||||||
|
|
||||||
|
float double_circ_seat(float x, float a) {
|
||||||
|
a = clamp(a, 0., 1.);
|
||||||
|
|
||||||
|
if (x<=a){
|
||||||
|
return sqrt(pow(a, 2.) - pow(x-a, 2.));
|
||||||
|
}
|
||||||
|
return 1. - sqrt(pow(1.-a, 2.) - pow(x-a, 2.));
|
||||||
|
}
|
||||||
|
|
||||||
|
float double_circ_sigmoid(float x, float a) {
|
||||||
|
a = clamp(a, 0., 1.);
|
||||||
|
|
||||||
|
if (x<=a){
|
||||||
|
return a - sqrt(pow(a, 2.) - pow(x, 2.));
|
||||||
|
}
|
||||||
|
return a + sqrt(pow(1.-a, 2.) - pow(x-1., 2.));
|
||||||
|
}
|
||||||
|
|
||||||
|
float double_ellip_seat(float x, vec2 ab) {
|
||||||
|
float e = 0.00001;
|
||||||
|
float a = clamp(ab.x, 0.+e, 1.+e);
|
||||||
|
float b = clamp(ab.y, 0., 1.);
|
||||||
|
|
||||||
|
if (x<=a){
|
||||||
|
return (b/a) * sqrt(pow(a, 2.) - pow(x-a, 2.));
|
||||||
|
}
|
||||||
|
return 1.-((1.-b)/(1.-a))*sqrt(pow(1.-a, 2.)-pow(x-a,2.));
|
||||||
|
}
|
||||||
|
|
||||||
|
float double_ellip_sigmoid(float x, vec2 ab) {
|
||||||
|
float e = 0.00001;
|
||||||
|
float a = clamp(ab.x, 0.+e, 1.+e);
|
||||||
|
float b = clamp(ab.y, 0., 1.);
|
||||||
|
|
||||||
|
if (x<=a){
|
||||||
|
return b * (1. - (sqrt(pow(a, 2.) - pow(x, 2.))/a));
|
||||||
|
}
|
||||||
|
return b+((1.-b)/(1.-a))*sqrt(pow(1.-a,2.)-pow(x-1.,2.));
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user