
function clear(obj)
{
    var childs = obj.childNodes;
    for (var i=0; i<childs.length; i++) {
        obj.removeChild(childs[i]);
    }
}

function effectiveDiamCm(diam)
{
    return diam*2.54 - 3.1;
}

function calcVel(diam, rot)
{
    return(effectiveDiamCm(diam) * Math.PI * rot * 6.0 / 10000.);
}

function outputVel(diam, rot)
{
    var out = document.getElementById('velocidad');
    clear(out);
    out.appendChild(document.createTextNode(Math.round(calcVel(diam, rot))));
}

function calcMaxSlope(R, r)
{
    return Math.asin(2*r/(R*Math.PI));
}

function calcMinVel(R, r)
{
    return 3.6 * R * Math.sqrt(4.126 * r/(R*R));
}

function outputMaxSlope(wdiam, r)
{
    var R = 10*effectiveDiamCm(wdiam)/2;
    var out = document.getElementById('maxSlope');
    clear(out);
    var mslope = calcMaxSlope(R, r);
    out.appendChild(document.createTextNode(Math.round(180*mslope/Math.PI)));
    out = document.getElementById('maxSlopePer');
    clear(out);
    out.appendChild(document.createTextNode(Math.round(100*Math.tan(mslope))));
    //out = document.getElementById('minSpeed');
    //clear(out);
    //out.appendChild(document.createTextNode(Math.round(calcMinVel(R, r))));
}


