Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 13-05-2005, 21:14   #1 (permalink)
Neuer User
 
Benutzerbild von zillion42
 
Registriert seit: Oct 2004
Beiträge: 65
Länge und Breite in X und Z konvertieren

Hallo nochmal,

Ich habe da vom Eagle Dynamics Entwickler Team diese Formel in C++ um Längen und Breiten Grade in brauchbare lineare XZ Koordinaten umzuwandeln... Für mein Radar Lotsen Projekt (Einfach nur auf connect drücken, mit der "R" Taste geht das Lineal an...)

PHP-Code:
const float zeroX 5000000.f// Real coordinates beginning
const float zeroZ 6600000.f;

const 
float centerX 11465000.f zeroX// Circle center
const float centerZ 6500000.f zeroZ;

const 
float pn40x24_X 4468608.57f zeroX// point 40dgN : 24dgE
const float pn40x24_Z 5730893.72f zeroZ;

const 
float pn48x24_X 5357858.31f zeroX// point 48dgN : 24dgE
const float pn48x24_Z 5828649.53f zeroZ;

const 
float pn40x42_X 4468608.57f zeroX// point 40dgN : 42dgE
const float pn40x42_Z 7269106.20f zeroZ;

const 
float pn48x42_X 5357858.31f zeroX// ????? 48dgN : 42dgE
const float pn48x42_Z 7171350.00f zeroZ;

// distances from the circle center to 48dgN and 40dgN
const double lenNorth sqrt((pn48x24_X-centerX)*(pn48x24_X-centerX) + (pn48x24_Z-centerZ)*(pn48x24_Z-centerZ));
const 
double lenSouth sqrt((pn40x24_X-centerX)*(pn40x24_X-centerX) + (pn40x24_Z-centerZ)*(pn40x24_Z-centerZ));
const 
double lenN_S lenSouth lenNorth;

const 
double RealAngleMaxLongitude atan (((double)pn40x24_Z centerZ)/(pn40x24_X centerX)) * 180.f PI;

// Map bounds. Degrees!
const float EndWest 24.f;
const 
float EndEast 42.f;
const 
float EndNorth 48.f;
const 
float EndSouth 40.f;
const 
float MiddleLongitude = (EndWest EndEast) / 2;

const 
float ToLengthN_S = (float)((EndNorth EndSouth) / lenN_S);
const 
double ToAngleW_E = (MiddleLongitude EndWest) / RealAngleMaxLongitude;
const 
double ToDegree 180. PI;

void GetCoords(double inLatitudeGraddouble inLongitudeGradfloat &outXfloat &outZ)
{
double realAng = (inLongitudeGrad MiddleLongitude) / ToAngleW_E ToDegree;
double realLen lenSouth - (inLatitudeGrad EndSouth) / ToLengthN_S;
outX centerX realLen cos (realAng);
outZ centerZ realLen sin (realAng);

Jetzt hab ich versucht die Formel in Actionscript umzubauen...

PHP-Code:
function latlong2xz (inLongitudeGrad,inLatitudeGrad) {

ToDegree 180/Math.PI;

zeroX 5000000;
zeroZ 6600000;

centerX 11465000-zeroX;
centerZ 6500000-zeroZ;

pn40x24_X 4468608.57-zeroX// point 40dgN : 24dgE
pn40x24_Z 5730893.72-zeroZ;

pn48x24_X 5357858.31-zeroX// point 48dgN : 24dgE
pn48x24_Z 5828649.53-zeroZ;

pn40x42_X 4468608.57-zeroX// point 40dgN : 42dgE
pn40x42_Z 7269106.20-zeroZ;

pn48x42_X 5357858.31-zeroX// point 48dgN : 42dgE
pn48x42_Z 7171350.00-zeroZ;

// distances from the circle center to 48dgN and 40dgN

lenNorth Math.sqrt((pn48x24_X-centerX)*(pn48x24_X-centerX)+(pn48x24_Z-centerZ)*(pn48x24_Z-centerZ));
lenSouth Math.sqrt((pn40x24_X-centerX)*(pn40x24_X-centerX)+(pn40x24_Z-centerZ)*(pn40x24_Z-centerZ));
lenN_S lenSouth-lenNorth;

RealAngleMaxLongitude Math.atan((pn40x24_Z-centerZ)/(pn40x24_X-centerX))*ToDegree;

// Map bounds. Degrees!
EndWest 24;
EndEast 42;
EndNorth 48;
EndSouth 40;

MiddleLongitude = (EndWest+EndEast)/2;
ToLengthN_S = (EndNorth-EndSouth)/lenN_S;
ToAngleW_E = (MiddleLongitude-EndWest)/RealAngleMaxLongitude;

realAng = (inLongitudeGrad-MiddleLongitude)/ToAngleW_E/ToDegree;
realLen lenSouth-(inLatitudeGrad-EndSouth)/ToLengthN_S;
outX centerX-realLen*Math.cos(realAng);
outZ centerZ+realLen*Math.sin(realAng);
return 
outX+" : "+outZ


klappt nur leider nicht richtig. D.h. Sie rechnet zwar, nur leider falsch. In C++ (davon kaum Ahnung) habe ich sie kompiliert gekriegt und siehe da, sie rechnet und auch noch richtig...

Wenn mir einer helfen mag wäre ich sehr dankbar...

Mit dieser .exe... kann man dann überprüfen ob sie funktioniert... Die .exe in der Eingabeaufforderung ausführen und ganz wichtig, . (Punkt) als Trennzeichen verwenden....

Danke vielmals im vorraus...

Zillion

Geändert von zillion42 (13-05-2005 um 21:29 Uhr)
zillion42 ist offline   Mit Zitat antworten
Alt 14-05-2005, 00:18   #2 (permalink)
Techniker
 
Benutzerbild von hgseib
 
Registriert seit: Sep 2003
Ort: 64807
Beiträge: 16.322
la-lo
void GetCoords(double inLatitudeGrad, double inLongitudeGrad, ..

lo-la
function latlong2xz (inLongitudeGrad,inLatitudeGrad)

der rest ist identisch
__________________
die ultimative antwort auf alle programmierfragen: der debugger
mfg h.g.seib www.SeibsProgrammLaden.de
hgseib ist offline   Mit Zitat antworten
Alt 15-05-2005, 15:06   #3 (permalink)
Neuer User
 
Benutzerbild von zillion42
 
Registriert seit: Oct 2004
Beiträge: 65
Hat sich geklärt...

Danke
zillion42 ist offline   Mit Zitat antworten
Antwort

Lesezeichen

Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks sind an
Pingbacks sind an
Refbacks sind an



Alle Zeitangaben in WEZ +1. Es ist jetzt 19:17 Uhr.

Domains, Webhosting & Vserver von Host Europe
Unterstützt das Flashforum!
Adobe User Group


Copyright ©1999 – 2012 Marc Thiele