Advertisement
Guest User

Untitled

a guest
Aug 17th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. static float[] RotateVector(float[] v, float degrees)
  2. {
  3. float sin = (float)Math.Sin(degrees * 0.0174553294f);
  4. float cos = (float)Math.Cos(degrees * 0.0174553294f);
  5.  
  6. float tx = v[0];
  7. float ty = v[1];
  8.  
  9.  
  10. return new float[] { (cos * tx) - (sin * ty), (sin * tx) + (cos * ty) };
  11. }
  12.  
  13.  
  14.  
  15. static void Main(string[] args)
  16. {
  17.  
  18. float lat = 53.1324886f;
  19. float lon = 23.1688403f;
  20.  
  21. float R = 6378137;
  22.  
  23. float distance = 100;
  24.  
  25. float dn = 0;
  26. float de = 1;
  27.  
  28. float[] rotation = RotateVector(new float[] { dn, de }, 180);
  29.  
  30. rotation[0] = rotation[0] * distance;
  31. rotation[1] = rotation[1] * distance;
  32.  
  33. float dLat = rotation[0] / R;
  34. float dLon = rotation[1] / (R * (float)Math.Cos(Math.PI * lat / 180));
  35.  
  36.  
  37. float latO = lat + dLat * 180 / (float)Math.PI;
  38. float lonO = lon + dLon * 180 / (float)Math.PI;
  39.  
  40. Console.WriteLine(latO+" "+ lonO);
  41.  
  42. Console.ReadKey();
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement