Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. public const int a = 6378137;
  2. public const double f = 1 / 298.257222101;
  3. public const double lowerLatitude = 49.8333333 * Mathf.Deg2Rad;
  4. public const double upperLatitude = 51.1666667 * Mathf.Deg2Rad;
  5. public const double originLatitude = 50.797815 * Mathf.Deg2Rad;
  6. public const double originLongitude = 4.359215833 * Mathf.Deg2Rad;
  7. public const int originX = 649328;
  8. public const int originY = 665262;
  9.  
  10. public static double Excentricity {get => System.Math.Sqrt((2 * f) - (f * f));}
  11.  
  12. static double MLower { get => M(lowerLatitude);}
  13. static double MUpper { get => M(upperLatitude);}
  14.  
  15. static double M(double latitude)
  16. {
  17. return System.Math.Cos(latitude) / System.Math.Sqrt(1 - (Excentricity * Excentricity * System.Math.Pow(System.Math.Sin(latitude), 2)));
  18. }
  19.  
  20. static double TLower { get => T(lowerLatitude); }
  21. static double TUpper { get => T(upperLatitude); }
  22. static double TOrigin { get => T(originLatitude); }
  23.  
  24. static double T(double latitude)
  25. {
  26.  
  27. return System.Math.Tan(Mathf.PI / 4 - latitude / 2) / System.Math.Pow((1 - Excentricity * System.Math.Sin(latitude)) / (1 + Excentricity * System.Math.Sin(latitude)), Excentricity / 2);
  28. }
  29.  
  30. static double N { get => (System.Math.Log(MLower) - System.Math.Log(MUpper)) / (System.Math.Log(TLower) - System.Math.Log(TUpper)); }
  31.  
  32. static double G { get => MLower / (N * System.Math.Pow(TLower, N)); }
  33.  
  34. static double ROrigin { get => R(TOrigin); }
  35.  
  36. static double R (double t)
  37. {
  38. return a * G * System.Math.Pow(t, N);
  39. }
  40.  
  41. public static Vector2 FromGeographicRelative(Vector2 coordinates)
  42. {
  43.  
  44. double t = T((double)coordinates.x * Mathf.Deg2Rad);
  45. double r = R(t);
  46. double angle = N * ((double)coordinates.y * Mathf.Deg2Rad - originLongitude);
  47. Vector2 lambertCoord = new Vector2
  48. {
  49. x = (float) (r * System.Math.Sin(angle)),
  50. y = (float) (ROrigin - r * System.Math.Cos(angle))
  51. };
  52. return lambertCoord;
  53.  
  54. }
  55.  
  56. if (((condition1 && condition2) || (condition3 && condition4)) && condition5) { ... }
  57.  
  58. if ((MyFirstCondition() || MySecondCondition()) && MyLastCondition()) { ... }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement