function RotationElipsoid(semimajor, invertF, orientation) {
	this.className = "RotationElipsoid";

	this.orientation = orientation;
	this.semimajor = semimajor;
	this.flattening = 1/invertF;
	this.semiminor = this.semimajor - this.semimajor * this.flattening;
	this.e2 = (Math.pow(this.semimajor,2) - Math.pow(this.semiminor,2)) / Math.pow(this.semimajor,2);
	//this.semiminor = Math.sqrt(Math.pow(this.semimajor,2) - e2 * Math.pow(this.semimajor,2));
	//this.flattening = (this.semimajor - this.semiminor) / this.semimajor;
	
	this.CurvationRatio = function(myPoint) {
		var e2 = this.e2;
		return this.semimajor * (1 - e2) / Math.sqrt(Math.pow(1 - e2 * Math.pow(Math.sin(myPoint.radians.latitude),2),3));
	}
	
	this.GrandNormal = function(myPoint) {
		var e2 = this.e2;
		return this.semimajor / Math.sqrt(1 - e2 * Math.pow(Math.sin(myPoint.radians.latitude),2));	
	}
}

function Orientation(translation_yz, translation_xz, translation_xy, refactor, rotation_x, rotation_y, rotation_z) {
	this.translation_xy = translation_xy;
	this.translation_yz = translation_yz;
	this.translation_xz = translation_xz;
	if (!refactor) { this.refactor = 0; } else { this.refactor = refactor; }
	if (!rotation_x) { this.rotation_x = 0; } else { this.rotation_x = rotation_x; }
	if (!rotation_y) { this.rotation_y = 0; } else { this.rotation_y = rotation_y; }
	if (!rotation_z) { this.rotation_z = 0; } else { this.rotation_z = rotation_z; }
}

/**
 * centro: nel centro di massa della terra
 * asse Z: passante per il polo Nord, come definito dal BIH nel 1984
 * asse X: passante per il meridiano di Greenwich, come definito dal BIH nel 1984
 * asse Y: scelto in modo da dare una terna destrorsa, ovvero tale che un osservatore posto lungo l'asse Z veda l'asse X sovrapporsi a Y con moto antiorario, il che pone Y in Asia.
 */
/*
var WGS84_Hayford = new RotationElipsoid(6378137.0,0.00669437999, new Orientation(0,0,0));
var ITA40 = new RotationElipsoid(6378388,0.00672267002, new Orientation(-104.1,-49.1,-9.9,-11.68,0.971,-2.917,0.714));
var ED50 = new RotationElipsoid(6378388,0.00672267002, new Orientation(-87,-98,-121));
*/
var WGS84_Hayford = new RotationElipsoid(6378137.0, 298.257222101, new Orientation(0,0,0));
var ED50 = new RotationElipsoid(6378388,297, new Orientation(-87,-98,-121));
