// BLT+A Point2D Class Ver.002 -alpha05
function Point2D(){
	
	this.x = null;
	this.y = null;
	
	var a = arguments;
	switch(a.length){
		case 0 : default : this.x = this.y = 0; break;
		case 1 : {
			if(typeof a[0] == "object") {
				var o = a[0];
				if(a[0].constructor == Point2D){
					this.x = o.x;
					this.y = o.y;
				} else if(a[0].constructor == Array){
					this.x = o[0];
					this.y = o[1];
				} else{
					this.x = this.y = 0; // r~`
				}
			} else
				this.x = this.y = a[0];
			break;
		}
		case 2 : {
			this.x = a[0];
			this.y = a[1];
			break;
		}
	}
}

function setBasicMemberPoint2D(){
	var P = Point2D;
	var PP = P.prototype;
	
	PP.set = function(){
		var a = arguments;
		if( a.length == 1 ){
			this.x = a[0].x;
			this.y = a[0].y;
		} else {
			this.x = a[0];
			this.y = a[1];
		}
	};
	PP.setX = function(x){ this.x = x;};
	PP.setY = function(y){ this.y = y;};
	PP.isNaN = function(){
		return (isNaN(this.x)||isNaN(this.y) || this.x == "" || this.y == "");
	};
	PP.equals = function( p ){
		return this.x === p.x && this.y === p.y;
	};
	
	PP.scale = function(v){
		this.x *= v;
		this.y *= v;
	};
	PP.add = function(p){
		this.x += p.x;
		this.y += p.y;
	};
	PP.sub = function(p){
		this.x -= p.x;
		this.y -= p.y;
	};
	
	PP.copy = function(){
		return new Point2D( this );
	};
	
	PP.toString = function(){
		return "Point2D : ( " + this.x + " , " + this.y + " )";
	};
} setBasicMemberPoint2D();
