## gearSDF (`lygia`/`sdf`/`gearSDF`)

Returns a gear shaped SDF Some notes about the parameters: * b determines the length and roundness of the spokes * n is the number of spokes

Dependencies:

Use:

``````gearSDF(<vec2> st, <vec2> center, <float> b, <int> n_spokes);
``````
``````gearSDF(<vec2> st, <float> b, <int> n_spokes);
``````

Check it on Github

``````

#ifndef FNC_GEARSDF
#define FNC_GEARSDF
float gearSDF( vec2 st, float b, int N) {
const float e = 2.71828182845904523536;
#ifdef CENTER_2D
st -= CENTER_2D;
#else
st -= 0.5;
#endif
st *= 3.0;
float s = map(b, 1.0, 15.0, 0.066, 0.5);
float d = length(st) - s;
float omega = b * sin(float(N) * atan(st.y, st.x));
float l = pow(e, 2.0 * omega);
float hyperTan = (l - 1.0) / (l + 1.0);
float r = (1.0/b) * hyperTan;
return (d + min(d, r));
}
#endif
``````

Dependencies:

Use:

``````gearSDF(<float2> st, <float2> center, <float> b, <int> n_spokes);
``````
``````gearSDF(<float2> st, <float> b, <int> n_spokes);
``````

Check it on Github

``````

#ifndef FNC_GEARSDF
#define FNC_GEARSDF
float gearSDF( float2 st, float b, int N) {
const float e = 2.71828182845904523536;
#ifdef CENTER_2D
st -= CENTER_2D;
#else
st -= 0.5;
#endif
st *= 3.0;
float s = map(b, 1.0, 15.0, 0.066, 0.5);
float d = length(st) - s;
float omega = b * sin(float(N) * atan2(st.y, st.x));
float l = pow(e, 2.0 * omega);
float hyperTan = (l - 1.0) / (l + 1.0);
float r = (1.0/b) * hyperTan;
return (d + min(d, r));
}
#endif
``````