ngLockEngaged = true;
                    rotatingLockAngle = Math.atan((loc.y - polygonRotating.y) /
                        (loc.x - polygonRotating.x));
                }
            }
        }
        else {
            startDragging(loc);
            dragging = true;
        }
    };

    canvas.onmousemove = function (e) {
        var loc = windowToCanvas(e),
            radius = Math.sqrt(Math.pow(loc.x - dragging.x, 2) +
                Math.pow(loc.y - dragging.y, 2)),
            angle;


       