1   package org.wcb.e6b;
2   
3   import java.text.DecimalFormat;
4   
5   /**
6    * Created by IntelliJ IDEA.
7    * User: wbogaardt
8    * Date: Aug 23, 2005
9    * Time: 9:44:52 AM
10   * To change this template use File | Settings | File Templates.
11   */
12  
13  public class Xhwind extends AbstractE6B {
14  
15      private int windSpeed = 0;
16      private int windDirection = 0;
17      private int runwayDirection = 0;
18  
19      private double headwind;
20      private double crosswind;
21  
22      public int getWindDirection() {
23          return windDirection;
24      }
25  
26      public void setWindDirection(int wd) {
27          this.windDirection = wd;
28      }
29  
30      public int getRunwayDirection() {
31          return runwayDirection;
32      }
33  
34      public void setRunwayDirection(int rnwy) {
35          int returnValue = rnwy;
36          if (rnwy > 36)
37          {
38              returnValue = rnwy / 10;
39          }
40          this.runwayDirection = returnValue * 10;
41      }
42  
43      public int getWindSpeed() {
44          return windSpeed;
45      }
46  
47      public void setWindSpeed(int ws) {
48          this.windSpeed = ws;
49      }
50  
51      public void calculate() {
52          System.out.println("runway is  " + runwayDirection);
53          headwind = windSpeed * Math.cos(Math.toRadians(windDirection - runwayDirection));
54          crosswind = windSpeed * Math.sin(Math.toRadians(windDirection - runwayDirection));
55      }
56  
57      public double getHeadwindResult() {
58          DecimalFormat df = new DecimalFormat("##.#");
59          return Double.parseDouble(df.format(headwind));
60      }
61  
62      public String getHeadwindDirection() {
63          if (headwind < 0)
64          {
65              return "tail wind";
66          }
67          return "headwind";
68      }
69  
70      public double getCrosswindResult() {
71          DecimalFormat df = new DecimalFormat("##.#");
72          return Double.parseDouble(df.format(crosswind));
73          //return crosswind;
74      }
75  
76      public String getCrossWindDirection() {
77          if (crosswind < 0)
78          {
79              return "left";
80          }
81          return "right";
82      }
83  }