vec3 DodecahedronIFS()

in src/elm_src/Algorithm/fractals.c [275:314]


vec3 DodecahedronIFS(vec3 w)
{
    w *= objectRotation;
    float d, t;
    float md = 1000.0, cd = 0.0;

    for (int i = 0; i < int(maxIterations); i++) {
        w *= fractalRotation1;
        w = abs(w + shift) - shift;

        t = w.x * phi3.z + w.y * phi3.y - w.z * phi3.x;
        if (t < 0.0) w += vec3(-2.0, -2.0, 2.0) * t * phi3.zyx;

        t = -w.x * phi3.x + w.y * phi3.z + w.z * phi3.y;
        if (t < 0.0) w += vec3(2.0, -2.0, -2.0) * t * phi3.xzy;

        t = w.x * phi3.y - w.y * phi3.x + w.z * phi3.z;
        if (t < 0.0) w += vec3(-2.0, 2.0, -2.0) * t * phi3.yxz;

        t = -w.x * c3.x + w.y * c3.y + w.z * c3.z;
        if (t < 0.0) w += vec3(2.0, -2.0, -2.0) * t * c3.xyz;

        t = w.x * c3.z - w.y * c3.x + w.z * c3.y;
        if (t < 0.0) w += vec3(-2.0, 2.0, -2.0) * t * c3.zxy;

        w *= fractalRotation2;
        w *= scale;
        w -= scale_offset;

        // Record minimum orbit for colouring
        d = dot(w, w);

        if (i < colorIterations) {
            md = min(md, d);
            cd = d;
        }
    }

    return vec3((length(w) - 2.0) * pow(scale, -float(maxIterations)), md, cd);
}