赞
踩
参考:http://blog.csdn.net/pz789as/article/details/52701371
放在这里以备以后自己需要:
- CompareGesture: function(line1, line2){//frechet距离算法
- var fval = 0;
- var ca = [];
- for(var i=0;i<line1.length;i++){
- ca.push([]);
- for(var j=0;j<line2.length;j++){
- ca[i][j] = -1;
- }
- }
- fval = Utils.CalDistance(line1, line2, ca, line1.length-1, line2.length-1);
- return fval;
- },
- CalDistance: function(line1, line2, arr, i, j){
- if (arr[i][j] > -1){
- return arr[i][j];
- }else if (i==0 && j==0){
- arr[i][j] = Utils.DisP(line1[0], line2[0]);//两点的距离
- }else if (i>0 && j==0){
- arr[i][j] = Math.max(Utils.CalDistance(line1,line2,arr,i-1,0), Utils.DisP(line1[i],line2[0]));
- }else if (i==0 && j>0){
- arr[i][j] = Math.max(Utils.CalDistance(line1,line2,arr,0,j-1), Utils.DisP(line1[0],line2[j]));
- }else if (i>0 && j>0){
- arr[i][j] = Math.max(Math.min(
- Utils.CalDistance(line1,line2,arr,i-1,j),
- Utils.CalDistance(line1,line2,arr,i-1,j-1),
- Utils.CalDistance(line1,line2,arr,i,j-1)),
- Utils.DisP(line1[i], line2[j])
- )
- }else{
- arr[i][j] = Number.MAX_VALUE;
- }
- return arr[i][j];
- },
备用~
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。