1 var YArrayStrip=function(arrayLength){
  2 	var scope=this;
  3 	this.strip=[];
  4 	var _re_sort=function(){
  5 		for(var i=0;i<scope.strip.length-1;i++){
  6 			for(var j=i+1;j<scope.strip.length;j++){
  7 				if(scope.strip[j].time<scope.strip[i].time){
  8 					var tmp = scope.strip[j];	scope.strip[j] = scope.strip[i];	scope.strip[i] = tmp;
  9 				}
 10 			}
 11 		}
 12 	};
 13 	
 14 	this.setAt=function(time,array){
 15 		if(typeof(time)!="number")throw("\nYArrayStrip.setAt Error:\nparameter 1:time("+typeof(time)+") must be a number!");
 16 		if(!array||!array.join)throw("\nYArrayStrip.setAt Error:\nparameter 2:array must be an array!");
 17 		if(array.length!=arrayLength)throw("\nYArrayStrip.setAt Error:\nparameter 2:array.length="+array.length+" must be "+arrayLength+"!");
 18 		var obj = {time:time,array:array};
 19 		var found = -1;
 20 		for(var i in this.strip)if(time-this.strip[i].time<0.00001){found = i;break;}
 21 		if(found>-1){
 22 			this.strip[found]=obj;
 23 		}else{
 24 			this.strip.push(obj);
 25 			_re_sort();
 26 		}
 27 	};
 28 	
 29 	this.getResultAt=function(time){
 30 		if(time<=this.strip[0].time)						return this.strip[0].array;
 31 		if(time>=this.strip[this.strip.length-1].time)	return this.strip[this.strip.length-1].array;
 32 		var i=0;
 33 		for(;i<this.strip.length-1&&time>this.strip[i+1].time;i++){}
 34 		var inperc = (time-this.strip[i].time)/(this.strip[i+1].time-this.strip[i].time);
 35 		var result = [];
 36 		for(k=0;k<arrayLength;k++){
 37 			result[k] = this.strip[i].array[k]*(1-inperc)+this.strip[i+1].array[k]*(inperc);
 38 		}
 39 		return result;
 40 	};
 41 	
 42 	this.getAt=function(time){
 43 		if(this.strip.length==0)throw("\nYArrayStrip.getAt Error:\nstrip.length=0:no strip datas set!");
 44 		var result = this.getResultAt(time);
 45 		return arrayLength==1?result[0]:result;
 46 	};
 47 };
 48 var YArrayStripCollection=function(collection){
 49 	var scope=this;
 50 	var build=function(){
 51 		if(collection){
 52 			for(var i in collection){
 53 				scope.setStrip(i,collection[i]);
 54 			}
 55 		}
 56 	};
 57 	this.strips={};
 58 	this.setStrip=function(name,yArrayStrip){
 59 		if(typeof(name)!="string")throw("\nYArrayStrip.setAt Error:\nparameter 1:name("+typeof(name)+") must be a string!");
 60 		if(!(yArrayStrip instanceof YArrayStrip))throw("\YArrayStripCollection.setStrip Error:\nparameter 2:yArrayStrip must be YArrayStrip!");
 61 		this.strips[name]=yArrayStrip;
 62 	};
 63 	this.getAt=function(time){
 64 		var result = {};
 65 		for(var i in this.strips){
 66 			result[i]=this.strips[i].getAt(time);
 67 		}
 68 		return result;
 69 	};
 70 	build();
 71 };