1 package net.sf.openrocket.util;
3 import static org.junit.Assert.*;
7 public class GeodeticComputationStrategyTest {
10 public void testAddCoordinate() {
12 double arcmin = (1.0 / 60.0);
13 double arcsec = (1.0 / (60.0 * 60.0));
15 double lat1 = 50.0 + 3 * arcmin + 59 * arcsec;
16 double lon1 = -1.0 * (5 + 42 * arcmin + 53 * arcsec); //W
18 double lat2 = 58 + 38 * arcmin + 38 * arcsec;
19 double lon2 = -1.0 * (3 + 4 * arcmin + 12 * arcsec);
21 double range = 968.9 * 1000.0;
22 double bearing = (9.0 + 7 * arcmin + 11 * arcsec) * (Math.PI / 180.0);
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);
28 System.out.println(wc.getLatitudeDeg());
29 System.out.println(lat2);
31 System.out.println(wc.getLongitudeDeg());
32 System.out.println(lon2);
34 assertEquals(lat2, wc.getLatitudeDeg(), 0.001);
35 assertEquals(lon2, wc.getLongitudeDeg(), 0.001);
36 assertEquals(1000.0, wc.getAltitude(), 0.0);
40 public void testGetCoriolisAcceleration1() {
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);