function GaussConverter(surface) {
	this.className = "GaussConverter";	
	this.defaultIntegralStep = 10000;
	
	this.a = surface.semimajor;
	this.e2 = surface.e2;
	
	this.Integral_Function = function(val, scope) {
		var a = scope.a;
		var e2 = scope.e2;
		var tempVal = (a * (1 - e2));
		return tempVal/Math.sqrt(Math.pow(1 - e2 * Math.pow(Math.sin(val),2),3));
	}
	
	this.convert = function(myPoint, precision) {
		if (!precision) { precision = this.defaultIntegralStep; }
		var a = this.a;
		var e2 = this.e2;
		
		var fuse_length = 6 * Math.PI / 180;
		
		//TODO: calcolare il fuso meglio
		var fuse;
		if (myPoint.radians.longitude > Math.PI)
			fuse = Math.floor((myPoint.radians.longitude - Math.PI) / fuse_length);
		else
			fuse = Math.floor((myPoint.radians.longitude + Math.PI) / fuse_length);
		var deltalength = (fuse - 30) * fuse_length + fuse_length / 2;
		
		var latitude = myPoint.radians.latitude;
		var longitude = myPoint.radians.longitude - deltalength;
		
		var sinLatitude = Math.sin(latitude);
		var cosLatitude = Math.cos(latitude);
		var tanLatitude = Math.tan(latitude);
		
		var tempVar1 = Math.sqrt(1 - e2 * Math.pow(sinLatitude, 2));
		var tempVar2 = Math.pow(e2/Math.sqrt(1 - e2), 2);
		
		var valoreIntegrale = Integral(this.Integral_Function, this, 0, latitude, precision);
		
		var x =  valoreIntegrale + 
					(1/2 * a*sinLatitude*cosLatitude / tempVar1) * Math.pow(longitude,2) +
					(1/24 * a*sinLatitude*Math.pow(cosLatitude, 3)) / tempVar1 * (
							5 - Math.pow(tanLatitude,2) + 9*tempVar2*Math.pow(cosLatitude,2) + 
							4 * Math.pow(tempVar2, 2)* Math.pow(cosLatitude,4) 
					) * Math.pow(longitude,4) +
					1/720 * a*sinLatitude*Math.pow(cosLatitude, 5)/ tempVar1 * (
							61 - 58*Math.pow(tanLatitude,2) + Math.pow(tanLatitude, 4) + 270 * tempVar2 * Math.pow(cosLatitude, 2) -
							330 * tempVar2 * Math.pow(cosLatitude, 2) * Math.pow(tanLatitude,2)
					) * Math.pow(longitude, 6);
		
		var y = 	(a * cosLatitude / tempVar1) * longitude + 
					(1/6) * a * Math.pow(cosLatitude, 3) / tempVar1 * (
							1 - Math.pow(tanLatitude,2) + tempVar2 * Math.pow(cosLatitude, 2)
					) * Math.pow(longitude, 3) +
					(1/120) * a*Math.pow(cosLatitude, 5) / tempVar1 * (
							5 - 18 * Math.pow(tanLatitude, 2) + Math.pow(tanLatitude, 4) + 14 * tempVar2 * Math.pow(cosLatitude, 2) -
							58 * tempVar2 * Math.pow(cosLatitude, 2) * Math.pow(tanLatitude, 2)
					) * Math.pow(longitude, 5);
		
		return [x,y,myPoint.altitude];
	}
}
