From 1f1cf4bd16201b59514a23b261de1ea0f1ae4cdb Mon Sep 17 00:00:00 2001 From: hellerve Date: Tue, 6 Jun 2017 07:59:54 -0400 Subject: [PATCH] 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) --- utilities/flong.glsl | 50 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/utilities/flong.glsl b/utilities/flong.glsl index c161bc2..fdb89b1 100644 --- a/utilities/flong.glsl +++ b/utilities/flong.glsl @@ -265,3 +265,53 @@ float cubic_bezier_through(float x, vec2 a, vec2 b) { return clamp(y, 0., 1.); } // 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.)); +}