geodetic computations
[debian/openrocket] / test / net / sf / openrocket / util / GeodeticComputationStrategyTest.java
1 package net.sf.openrocket.util;
2
3 import static org.junit.Assert.*;
4
5 import org.junit.Test;
6
7 public class GeodeticComputationStrategyTest {
8         
9         @Test
10         public void testAddCoordinate() {
11                 
12                 double arcmin = (1.0 / 60.0);
13                 double arcsec = (1.0 / (60.0 * 60.0));
14                 
15                 double lat1 = 50.0 + 3 * arcmin + 59 * arcsec;
16                 double lon1 = -1.0 * (5 + 42 * arcmin + 53 * arcsec); //W 
17                 
18                 double lat2 = 58 + 38 * arcmin + 38 * arcsec;
19                 double lon2 = -1.0 * (3 + 4 * arcmin + 12 * arcsec);
20                 
21                 double range = 968.9 * 1000.0;
22                 double bearing = (9.0 + 7 * arcmin + 11 * arcsec) * (Math.PI / 180.0);
23                 
24                 Coordinate coord = new Coordinate(range * Math.sin(bearing), range * Math.cos(bearing), 1000.0);
25                 WorldCoordinate wc = new WorldCoordinate(lat1, lon1, 0.0);
26                 wc = GeodeticComputationStrategy.SPHERICAL.addCoordinate(wc, coord);
27                 
28                 System.out.println(wc.getLatitudeDeg());
29                 System.out.println(lat2);
30                 
31                 System.out.println(wc.getLongitudeDeg());
32                 System.out.println(lon2);
33                 
34                 assertEquals(lat2, wc.getLatitudeDeg(), 0.001);
35                 assertEquals(lon2, wc.getLongitudeDeg(), 0.001);
36                 assertEquals(1000.0, wc.getAltitude(), 0.0);
37         }
38         
39         @Test
40         public void testGetCoriolisAcceleration1() {
41                 
42                 // For positive latitude and rotational velocity, a movement due east results in an acceleration due south
43                 Coordinate velocity = new Coordinate(-1000, 0, 0);
44                 WorldCoordinate wc = new WorldCoordinate(45, 0, 0);
45                 double north_accel = GeodeticComputationStrategy.SPHERICAL.getCoriolisAcceleration(wc, velocity).y;
46                 System.out.println("North accel " + north_accel);
47                 assertTrue(north_accel < 0.0);
48                 
49         }
50         
51 }