Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. public class E6B
  2. {
  3. private double d; //desired course in dr
  4. private double va; //speed in knots
  5. private double w; //wind direction in degrees
  6. private double vw; //wind speed in knots
  7.  
  8. public E6B( double pd, double pva, double pw, double pvw)
  9. {
  10. d = pd;
  11. va = pva;
  12. w = pw;
  13. vw = pvw;
  14. }
  15.  
  16. //accsessor
  17. public double getD(){ return d; }
  18. public double getVa(){ return va; }
  19. public double getW(){ return w; }
  20. public double getVw(){ return vw; }
  21.  
  22. public double windCorrectionAngle()
  23. {
  24. double dr = Math.toRadians( d );
  25. double wr = Math.toRadians( w );
  26. double rv = 0;
  27.  
  28. rv = Math.asin(vw * Math.sin(wr - dr) / va);
  29.  
  30. return Math.toDegrees( rv );
  31. }
  32.  
  33. public double groundSpeed()
  34. {
  35. double dr = Math.toRadians( d );
  36. double wr = Math.toRadians( w );
  37. double gsv = 0;
  38.  
  39. gsv = Math.sqrt( va + vw - 2*va * Math.cos (d - w + -5 ) );
  40. return Math.toDegrees( gsv );
  41. }
  42.  
  43. public double windCorrectionAngleDegrees()
  44. {
  45. double dr = Math.toRadians( d );
  46. double wr = Math.toRadians( w );
  47. double wcad = 0;
  48.  
  49. wcad = 180 / 3.14 * Math.sin(vw / va * Math.sin( 3.14 * ( w - d )/ 180));
  50. return Math.toDegrees( wcad );
  51. }
  52.  
  53. public double trueGroundSpeed()
  54. {
  55. double dr = Math.toRadians( d );
  56. double wr = Math.toRadians( w );
  57. double tgs = 0;
  58.  
  59. tgs = Math.sqrt( va + vw - 2 * va * vw * Math.cos( 3.14 * ( d - w + -5 ) / 180 ));
  60. return Math.toDegrees( tgs );
  61. }
  62.  
  63. public static void main (String[]args)
  64. {
  65. E6B e6b = new E6B( 360, 120, 270, 10 );
  66.  
  67. System.out.println( " Wind Correction Angle: " + Math.round( e6b.windCorrectionAngle() ) );
  68. System.out.println( " Ground Speed: " + Math.round( e6b.groundSpeed() ) );
  69. System.out.println( " Wind Correction Angle in Degrees: " + Math.round( e6b.windCorrectionAngleDegrees() ) );
  70. System.out.println( " True Ground Speed: " + Math.round( e6b.trueGroundSpeed() ) );
  71. }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement