Ein Quadrat um einen lathen Punkt zeichnenC#

Ein Treffpunkt für C#-Programmierer
Guest
 Ein Quadrat um einen lathen Punkt zeichnen

Post by Guest »

Ich versuche ein Quadrat um einen bestimmten Punkt auf der Erdoberfläche zu zeichnen. Hier und hier und letztendlich dazu gekommen:-< /p>

// Converting degrees to radians
double latInDecimals = (Math.PI / 180) * latitude;
double longInDecimals = (Math.PI / 180) * longitude;

List lstStrCoords = new List();

double changeInLat;
double changeInLong;
double lineOfLat;

// Calculating change in latitude for square of side
changeInLong = (side / 1000) * (360.0 / 40075);

// Calculating length of longitude at that point of latitude
lineOfLat = Math.Cos(longitude) * 40075;

// Calculating change in longitude for square of side 'side'
changeInLat = (side / 1000) * (360.0 / lineOfLat);

// Converting changes into radians
changeInLat = changeInLat * (Math.PI / 180);
changeInLong = changeInLong * (Math.PI / 180);

double nLat = changeInLat * (Math.Sqrt(2) / 2);
double nLong = changeInLong * (Math.Sqrt(2) / 2);

double coordLat1 = latInDecimals + nLat;
double coordLong1 = longInDecimals + nLong;

double coordLat2 = latInDecimals + nLat;
double coordLong2 = longInDecimals - nLong;

double coordLat3 = latInDecimals - nLat;
double coordLong3 = longInDecimals - nLong;

double coordLat4 = latInDecimals - nLat;
double coordLong4 = longInDecimals + nLong;

// Converting coords back to degrees

coordLat1 = coordLat1 * (180 / Math.PI);
coordLat2 = coordLat2 * (180 / Math.PI);
coordLat3 = coordLat3 * (180 / Math.PI);
coordLat4 = coordLat4 * (180 / Math.PI);

coordLong1 = coordLong1 * (180 / Math.PI);
coordLong2 = coordLong2 * (180 / Math.PI);
coordLong3 = coordLong3 * (180 / Math.PI);
coordLong4 = coordLong4 * (180 / Math.PI);
< /code>

Nun, obwohl dies funktioniert, ist das Polygon, das ich durch das Verbinden von dieser bekomme Alt = "Bildbeschreibung hier eingeben" src = "https://i.static.net/ag5w9.png"/>

Ich bin verwirrt darüber, was falsch ist mit meinem Code.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post