/*
some trigonometric calculation of rotational parameters for javascript selectable RASP maps.

Copyright (C) 2010 Thomas Pantzer

This program is free software; you can redistribute it and/or modify it under 
the terms of the GNU General Public License as published by the Free Software 
Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY 
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with 
this program; if not, see http://www.gnu.org/licenses/.
*/

if (recalc) {
	normA[0] = -aNx;
	normA[1] = -aNy;
	if (debug) {
		alert("normA("+normA[0]+","+normA[1]+")");
	}	
}

if (recalc) {
	Pr[0] = m1x + lR*Ax/la;
	Pr[1] = m1y + lR*Ay/la;
	if (debug) {
		alert("Pr("+Pr[0]+","+Pr[1]+")"+"  lR:"+lR );
	}
}

if (debug) {
	var Pr2 = new Array(2);
	Pr2[0] = 582.2958993165842;
	Pr2[1] = -3244.3872964941493;
	Pr2[0] = m4x + lR*Bx/lb;
	Pr2[1] = m4y + lR*By/lb;
	alert("la:"+la+" lb:"+lb+" Pr("+Pr2[0]+","+Pr2[1]+")");
}

if (recalc) {
	rStart = lR - la;
	if (debug) {
		 alert("rStart("+rStart+")");
	}
}	

if (recalc) {
	fLat = la / (eLt - sLt);
	if (debug) {
		alert("fLat("+fLat+")");
	}	
}

if (recalc) {
	var al = alpha(Ax, Ay, Bx, By);
	var dg = deg2rad(eLn - sLn);
	fLon =  al / dg; // 1.42730769230769230770;  nur für die schiefe Dänemark Karte
	if (debug) {
		alert("alpha(" +Ax+","+Ay+","+Bx+","+By+ "):"+al+" deg:"+dg+" fLon:"+fLon);
	}	
}


var vRot = new Array(2);
vRot[0] = -0.10835300070389564648;
vRot[1] = 0.99411248218622704784;

function rotate(a)
{
	c = Math.cos(-a);
	s = Math.sin(-a);
	vRot[0] = normA[0]*c   - normA[1]*s;
	vRot[1] = normA[0]*s   + normA[1]*c;
}


