function paramscale(base, kexp, scenter, pcenter, pmin, pmax)

N = 1000;
slider = (0:N)/N;

p = toParam(base, kexp, scenter, pcenter, pmin, pmax, slider);
s = toSlider(base, kexp, scenter, pcenter, pmin, pmax, p);

subplot (2, 1, 1)
plot (0:N, p); grid; xlabel('param');
subplot (2, 1, 2)
plot (0:N, s); grid; xlabel('slider');

function param = toParam(base, kexp, scenter, pcenter, pmin, pmax, slider)
	
%    pcenter = pmax*scenter + pmin*(1-scenter)

    for i=1:length(slider),
    	s = min(1, max(0, slider(i)));
        
        if (s < scenter)
            if (base == 1)
                p = pcenter-(pcenter-pmin)*(scenter-s)/scenter;
                % p = pcenter-(pcenter-pmin)*(scenter-s)/scenter;
            else
                p = pcenter-(pcenter-pmin)*(base^(kexp*(scenter-s)/scenter)-1)/(base^kexp-1);
                % p = pcenter-(pcenter-pmin)*(pow(base,kexp*(scenter-s)/scenter)-1)/(pow(base,kexp)-1);
            end
        else
            if (base == 1)
                p = pcenter+(pmax-pcenter)*(-scenter+s)/(1-scenter);
                % p = pcenter+(pmax-pcenter)*(-scenter+s)/(1-scenter);
            else
                p = pcenter+(pmax-pcenter)*(base^(kexp*(-scenter+s)/(1-scenter))-1)/(base^kexp-1);
                % p = pcenter+(pmax-pcenter)*(pow(base,kexp*(-scenter+s)/(1-scenter))-1)/(pow(base,kexp)-1);
            end;
        end
        param(i) = p;
    end
    
function slider = toSlider(base, kexp, scenter, pcenter, pmin, pmax, param)

%pcenter = pmax*scenter + pmin*(1-scenter);

    for i=1:length(param),
        p = param(i);
        
        if (p < pcenter)
            if (base == 1)
                s = (-pmin+p)*scenter/(pcenter-pmin);
                % s = (-pmin+p)*scenter/(pcenter-pmin);
            else
                s = scenter*(log(base)*kexp-log(-(-pcenter*base^kexp+pmin+p*base^kexp-p)/(pcenter-pmin)))/log(base)/kexp;
                % s = scenter*(log(base)*kexp-log(-(-pcenter*pow(base,kexp)+pmin+p*pow(base,kexp)-p)/(pcenter-pmin)))/log(base)/kexp;
            end
        else
            if (base == 1)
                s = (pcenter-scenter*pmax-p+scenter*p)/(-pmax+pcenter);
                % s = (pcenter-scenter*pmax-p+scenter*p)/(-pmax+pcenter);
            else
                s = (kexp*log(base)*scenter+log(-(-pcenter*base^kexp+pmax+p*base^kexp-p)/(-pmax+pcenter))-log(-(-pcenter*base^kexp+pmax+p*base^kexp-p)/(-pmax+pcenter))*scenter)/log(base)/kexp;
                % s = (kexp*log(base)*scenter+log(-(-pcenter*pow(base,kexp)+pmax+p*pow(base,kexp)-p)/(-pmax+pcenter))-log(-(-pcenter*pow(base,kexp)+pmax+p*pow(base,kexp)-p)/(-pmax+pcenter))*scenter)/log(base)/kexp;
            end
        end
        slider(i) = s;
    end
