Advertisement
Guest User

Untitled

a guest
Dec 12th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. #ifndef REGULATOR_C_
  2. #define REGULATOR_C_
  3.  
  4. #define FLAG_GPS
  5. #endif
  6.  
  7. if(FLAG_GPS == FLAG_GPS_SentPosition)
  8. {
  9. public cord2cart(double lat, double lon)
  10. {
  11. //CORD2CART Funkcja konwertuje położenie geograficzne wyrażone w stopniach
  12. //na położenie w lokalnym układzie kartezjańskim w m
  13. lat = lat * Math.PI / 180.0;
  14. lon = lon * Math.PI / 180.0;
  15. Point p = new Point();
  16. double a = 6378137.0; // promień Ziemi na równiku i biegunach
  17. double b = 6356752.3;
  18. double R = Math.Sqrt((Math.Pow(Math.Pow(a, 2) * Math.Cos(referencePoint_lat0Rad), 2) + Math.Pow(Math.Pow(b, 2) * Math.Sin(referencePoint_lat0Rad), 2)) / (Math.Pow(a * Math.Cos(referencePoint_lat0Rad), 2) + Math.Pow(b * Math.Sin(referencePoint_lat0Rad), 2)));
  19. //MessageBox.Show(R.ToString());
  20. p.X = (lon - referencePoint_lon0Rad) * R * Math.Sin(Math.PI / 2.0 - referencePoint_lat0Rad);
  21. p.Y = (lat - referencePoint_lat0Rad) * R;
  22. return p;
  23. }
  24.  
  25. double[] calcStraightLine(double x1, double y1, double x2, double y2) // Oblicza trajektorię jako prostą między dwoma punktami
  26. {
  27. double[] parameters = new double[2];
  28. double a = (y2 - y1) / (x2 - x1);
  29. double b = y1 - a * x1;
  30. parameters[0] = a;
  31. parameters[1] = b;
  32. return parameters;
  33. }
  34.  
  35. //oblicz orientację jaką powinien miec katamaran by byc na kursie do punktu (x,y)
  36. double calcOrientation(double a, double x) // xxx a współczynnik kierunkowy, x -
  37. {
  38. double ang = Math.Atan(a) * 180 / Math.PI;
  39. //textBlockFOO3.Text = ang.ToString("0.##");
  40. //textBlockFOO4.Text = x.ToString("0.##");
  41. if (x >= 0)
  42. {
  43. ang = 90 - ang;
  44. }
  45. else
  46. {
  47. ang = 270 - ang;
  48. }
  49. return ang;
  50. }
  51.  
  52. double calcDistanceToTrajectory(double X, double Y, double a, double b) // xxx co on tu liczy? // Pewnie odległość od punktu
  53. {
  54. double A = -a;
  55. double B = 1; // xxx ?
  56. double C = -b;
  57. return (A * X + B * Y + C) / Math.Sqrt(Math.Pow(A, 2) + Math.Pow(B, 2));
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement