Weaving Ring

Here is the more interesting part of the weaving algorithm


let weaveCounter = 0;

function weave( arrA, arrB, radius, weaveMax, weaveNum, weaveSpeed )
{
    for( let i = 0; i < 360; i += 2 )
    {
        let t = Math.sin( ( Math.abs( i - weaveCounter ) / 360 ) * PI );
        t = t * t * t * t * t;

        let ang = i * PI / 180;
        let off = Math.sin( ang * weaveNum ) * weaveMax * t;

        arrA.push( {
            x: ( radius + off ) * Math.cos( ang ),
            y: ( radius + off ) * Math.sin( ang )
        } );

        arrB.push( {
            x: ( radius - off ) * Math.cos( ang ),
            y: ( radius - off ) * Math.sin( ang )
        } );
    }

    weaveCounter = (weaveCounter + weaveSpeed) % 360;
}