Calculator.java 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. package weerstation;
  2. public class Calculator {
  3. public Calculator(){
  4. }
  5. // Luchtdruk in hPa
  6. // Malek&Tom
  7. public double luchtdruk(short mval)
  8. {
  9. double luchtdruk = (mval / 1000f) * 33.86389;
  10. return luchtdruk;
  11. }
  12. // Temperatuur in graden Celcius
  13. // Malek&Tom
  14. public double temperatuur(short mval)
  15. {
  16. double temperatuur = (((double)mval / 10) -32) / 1.8;
  17. return temperatuur;
  18. }
  19. // Relatieve luchtvochtigheid in %
  20. // Malek&Tom
  21. public double luchtVochtigheid(short mval)
  22. {
  23. double luchtvochtigheid = mval;
  24. return luchtvochtigheid;
  25. }
  26. // Windsnelheid in m/s
  27. // Janco&Tim
  28. public double windSnelheid(short mval)
  29. {
  30. double windSpeed = mval * 0.44704;
  31. return windSpeed;
  32. }
  33. // Windrichting in noord, oost, zuid en west.
  34. // Kenneth&Daniël
  35. public String windRichting(short mval)
  36. {
  37. String direction = "Error";
  38. if(mval < 12)
  39. {
  40. direction = "N";
  41. }
  42. else if(mval < 34)
  43. {
  44. direction = "NNO";
  45. }
  46. else if(mval < 57)
  47. {
  48. direction = "NO";
  49. }
  50. else if(mval < 79)
  51. {
  52. direction = "ONO";
  53. }
  54. else if(mval < 102)
  55. {
  56. direction = "O";
  57. }
  58. else if(mval < 124)
  59. {
  60. direction = "OZO";
  61. }
  62. else if(mval < 147)
  63. {
  64. direction = "ZO";
  65. }
  66. else if(mval < 169)
  67. {
  68. direction = "ZZO";
  69. }
  70. else if(mval < 192)
  71. {
  72. direction = "Z";
  73. }
  74. else if(mval < 214)
  75. {
  76. direction = "ZZW";
  77. }
  78. else if(mval < 237)
  79. {
  80. direction = "ZW";
  81. }
  82. else if(mval < 259)
  83. {
  84. direction = "WZW";
  85. }
  86. else if(mval < 282)
  87. {
  88. direction = "W";
  89. }
  90. else if(mval < 304)
  91. {
  92. direction = "WNW";
  93. }
  94. else if(mval < 327)
  95. {
  96. direction = "NW";
  97. }
  98. else if(mval < 349)
  99. {
  100. direction = "NNW";
  101. }
  102. else if(mval < 360)
  103. {
  104. direction = "N";
  105. }
  106. return direction;
  107. }
  108. // Regenmeter in mm
  109. // Kenneth&Daniël
  110. public double regenmeter(short mval)
  111. {
  112. double rainAmount = (double)mval*0.2;
  113. return rainAmount;
  114. }
  115. // uvIndex in index
  116. // Kenneth&Daniël
  117. public double uvIndex(short mval)
  118. {
  119. double index = (double) mval/10;
  120. return index;
  121. }
  122. // BatterySpanning in Volt
  123. // Janco&Tim
  124. public double batterySpanning(short mval){
  125. double voltage = (((double)mval * 300)/512)/100;
  126. return voltage;
  127. }
  128. // sunRise en Sunset in tijdformaat hh:mm
  129. // Janco&Tim
  130. public String sunRise(short mval){
  131. return sun(mval);
  132. }
  133. public String sunSet(short mval){
  134. return sun(mval);
  135. }
  136. private String sun(short sunRaw){
  137. String tijd = "";
  138. for(int i = 0; i <= 3; i++){
  139. tijd = sunRaw % 10 + tijd;
  140. sunRaw /= 10;
  141. if(i == 1){
  142. tijd = ":" + tijd;
  143. }
  144. }
  145. return tijd;
  146. }
  147. //windchill in graden Celcius
  148. //Janco en Keneth
  149. public double windChill(short gradenFahrenheit, short mijlPerUur)
  150. {
  151. short windChill = (short) (35.74 + (0.6215*gradenFahrenheit) - 35.75*Math.pow(mijlPerUur, 0.16) + 0.4275*gradenFahrenheit*Math.pow(mijlPerUur, 0.16));
  152. return temperatuur(windChill);
  153. }
  154. //Heatindex in celcius
  155. //Tom met Malek
  156. public double heatIndex(double luchtv, double t)
  157. {
  158. double heatindex = -42.379 + (2.04901523 * t) + (10.14333127 * luchtv) - (0.22475541 * t * luchtv)
  159. - (6.83783 * Math.pow(10,-3) * Math.pow(t,2)) - (5.481717 * Math.pow(10,-2) * Math.pow(luchtv,2))
  160. + (1.22874 * Math.pow(10,-3) * Math.pow(t,2) * luchtv) + (8.5282 * Math.pow(10,-4) * t * Math.pow(luchtv,2))
  161. - (1.99 * Math.pow(10,-6) * Math.pow(t,2) * Math.pow(luchtv,2));
  162. return heatindex;
  163. }
  164. //Dauwpunt in Celcius
  165. //Daniel en Tim
  166. public double dewPoint(double omgevingsTemp, short luchtVochtigheid)
  167. {
  168. double hm = luchtVochtigheid/100f;
  169. double dauwpunt = Math.pow( hm, (1/8f)) * (112 + 0.9*omgevingsTemp) + (0.1*omgevingsTemp) - 112;
  170. return dauwpunt;
  171. }
  172. public double cloudHeight(double temp, short luchtVochtigheid ){
  173. double wolkhoogte = 125 * (temp-dewPoint(temp, luchtVochtigheid));
  174. return wolkhoogte;
  175. }
  176. public void opdrachtEenA(){
  177. for(int i = 0; i<4; i++){
  178. }
  179. }
  180. }