• 图形数据处理(原创)


    document.myui_common = {
        //进度-假进度-以进度先执行,结果回调
        processBade:function(canvasId,store,callback){
            var pro = 0;
            var myrun = function(){
                if(pro>100){
                    callback(pro);
                    return;
                }else{
                    //设置中间进度数
                    var process_center = store[canvasId].process_center;
                    process_center.style.text = pro+'%';
                    pro++;
                    setTimeout(myrun,0)
                }
            }
            myrun();
        },
        //解析三维数组 poi指定方向
        getPackList:function(g3_point,splitIndex,poi){
            var self = this;
            var arry = self.getGpoint(g3_point,splitIndex,poi);
            var arrli = new Array();
            for(var i=0;i<arry.length;i++){
                var temp_arry = arry[i];
                for(var j=0;j<temp_arry.length;j++){
                    arrli.push(temp_arry[j]);
                }
            }
            return arrli;
        },
        //拐点遍历
        getGpoint:function(g3_point,splitIndex,poi){
            var self = this;
            var start = 0;
            var end = 1;
            var allList = new Array();
            var run = function(g3_point,splitIndex,start,end){
                if(end>=g3_point.length){
                    return;
                }
                var tempLi = [g3_point[start],g3_point[end]]
                var arry = self.splitLine(tempLi,splitIndex,poi);
                allList.push(arry);
                run(g3_point,splitIndex,start+1,end+1);
            }
            run(g3_point,splitIndex,start,end);
            return allList;
    
        },
        //细分坐标,两个点细分出多个点
        splitLine:function(g3_point,splitIndex,poi){
            var slist = new Array();
            var x1 = g3_point[0][0];
            var y1 = g3_point[0][1];
            var x2 = g3_point[1][0];
            var y2 = g3_point[1][1];
            if(x2==x1){
                var distance = parseFloat((Math.abs(y2-y1)/10).toFixed(2));
                for(var i=0;i<splitIndex;i++){
                    var x3 = x1;
                    var y3 = i*distance+y1;
                    var temp = new Array();
                    temp.push(x3);
                    temp.push(y3);
                    slist.push(temp);
                }
                return slist;
    
            }else{
                if(poi=='right'){
                    var k = ((y2-y1)/(x2-x1)).toFixed(2);
                    for(var i=0;i<splitIndex;i++){
                        var x3 = parseFloat((Math.abs(x2-x1)*((i+1)/splitIndex)).toFixed(2))+x1;//等分
                        var y3 = Math.abs(x3-x1)*k+y1;
                        var temp = new Array();
                        temp.push(x3);
                        temp.push(y3);
                        slist.push(temp);
                    }
                    return slist;
                }else if(poi=='left'){
                    var k = ((y2-y1)/(x2-x1)).toFixed(2);
                    for(var i=0;i<splitIndex;i++){
                        var x3 = x1-parseFloat((Math.abs(x1-x2)*(i/splitIndex)).toFixed(2));//等分
                        var y3 = Math.abs(x3-x1)*k+y1;
                        var temp = new Array();
                        temp.push(x3);
                        temp.push(y3);
                        slist.push(temp);
                    }
                    return slist;
                }
                
            }
            
        }
    }
    钟声敲响了日落
  • 相关阅读:
    [HNOI2004]宠物收养所 题解
    文艺平衡树(区间翻转)(Splay模板)
    搜索专题 题解
    Gorgeous Sequence 题解 (小清新线段树)
    花神游历各国 题解(小清新线段树/树状数组+并查集)
    [HNOI2012]永无乡 题解
    poj 3683 2-sat问题,输出任意一组可行解
    hdu 1824 2-sat问题(判断)
    hdu 4115 石头剪子布(2-sat问题)
    hdu 4421 和poj3678类似二级制操作(2-sat问题)
  • 原文地址:https://www.cnblogs.com/SATinnovation/p/6785534.html
Copyright © 2020-2023  润新知