Search in sources :

Example 1 with Equatorial

use of android.icu.impl.CalendarAstronomer.Equatorial in project j2objc by google.

the class AstroTest method TestSolarLongitude.

@Test
public void TestSolarLongitude() {
    GregorianCalendar gc = new GregorianCalendar(new SimpleTimeZone(0, "UTC"));
    CalendarAstronomer astro = new CalendarAstronomer();
    // year, month, day, hour, minute, longitude (radians), ascension(radians), declination(radians)
    final double[][] tests = { { 1980, 7, 27, 00, 00, 2.166442986535465, 2.2070499713207730, 0.3355704075759270 }, { 1988, 7, 27, 00, 00, 2.167484927693959, 2.2081183335606176, 0.3353093444275315 } };
    logln("");
    for (int i = 0; i < tests.length; i++) {
        gc.clear();
        gc.set((int) tests[i][0], (int) tests[i][1] - 1, (int) tests[i][2], (int) tests[i][3], (int) tests[i][4]);
        astro.setDate(gc.getTime());
        double longitude = astro.getSunLongitude();
        if (longitude != tests[i][5]) {
            if ((float) longitude == (float) tests[i][5]) {
                logln("longitude(" + longitude + ") !=  tests[i][5](" + tests[i][5] + ") in double for test " + i);
            } else {
                errln("FAIL: longitude(" + longitude + ") !=  tests[i][5](" + tests[i][5] + ") for test " + i);
            }
        }
        Equatorial result = astro.getSunPosition();
        if (result.ascension != tests[i][6]) {
            if ((float) result.ascension == (float) tests[i][6]) {
                logln("result.ascension(" + result.ascension + ") !=  tests[i][6](" + tests[i][6] + ") in double for test " + i);
            } else {
                errln("FAIL: result.ascension(" + result.ascension + ") !=  tests[i][6](" + tests[i][6] + ") for test " + i);
            }
        }
        if (result.declination != tests[i][7]) {
            if ((float) result.declination == (float) tests[i][7]) {
                logln("result.declination(" + result.declination + ") !=  tests[i][7](" + tests[i][7] + ") in double for test " + i);
            } else {
                errln("FAIL: result.declination(" + result.declination + ") !=  tests[i][7](" + tests[i][7] + ") for test " + i);
            }
        }
    }
}
Also used : SimpleTimeZone(android.icu.util.SimpleTimeZone) GregorianCalendar(android.icu.util.GregorianCalendar) CalendarAstronomer(android.icu.impl.CalendarAstronomer) Equatorial(android.icu.impl.CalendarAstronomer.Equatorial) Test(org.junit.Test)

Example 2 with Equatorial

use of android.icu.impl.CalendarAstronomer.Equatorial in project j2objc by google.

the class AstroTest method TestCoordinates.

@Test
public void TestCoordinates() {
    CalendarAstronomer astro = new CalendarAstronomer();
    Equatorial result = astro.eclipticToEquatorial(139.686111 * PI / 180.0, 4.875278 * PI / 180.0);
    logln("result is " + result + ";  " + result.toHmsString());
}
Also used : CalendarAstronomer(android.icu.impl.CalendarAstronomer) Equatorial(android.icu.impl.CalendarAstronomer.Equatorial) Test(org.junit.Test)

Example 3 with Equatorial

use of android.icu.impl.CalendarAstronomer.Equatorial in project j2objc by google.

the class AstroTest method TestLunarPosition.

@Test
public void TestLunarPosition() {
    GregorianCalendar gc = new GregorianCalendar(new SimpleTimeZone(0, "UTC"));
    CalendarAstronomer astro = new CalendarAstronomer();
    // year, month, day, hour, minute, ascension(radians), declination(radians)
    final double[][] tests = { { 1979, 2, 26, 16, 00, -0.3778379118188744, -0.1399698825594198 } };
    logln("");
    for (int i = 0; i < tests.length; i++) {
        gc.clear();
        gc.set((int) tests[i][0], (int) tests[i][1] - 1, (int) tests[i][2], (int) tests[i][3], (int) tests[i][4]);
        astro.setDate(gc.getTime());
        Equatorial result = astro.getMoonPosition();
        if (result.ascension != tests[i][5]) {
            if ((float) result.ascension == (float) tests[i][5]) {
                logln("result.ascension(" + result.ascension + ") !=  tests[i][5](" + tests[i][5] + ") in double for test " + i);
            } else {
                errln("FAIL: result.ascension(" + result.ascension + ") !=  tests[i][5](" + tests[i][5] + ") for test " + i);
            }
        }
        if (result.declination != tests[i][6]) {
            if ((float) result.declination == (float) tests[i][6]) {
                logln("result.declination(" + result.declination + ") !=  tests[i][6](" + tests[i][6] + ") in double for test " + i);
            } else {
                errln("FAIL: result.declination(" + result.declination + ") !=  tests[i][6](" + tests[i][6] + ") for test " + i);
            }
        }
    }
}
Also used : SimpleTimeZone(android.icu.util.SimpleTimeZone) GregorianCalendar(android.icu.util.GregorianCalendar) CalendarAstronomer(android.icu.impl.CalendarAstronomer) Equatorial(android.icu.impl.CalendarAstronomer.Equatorial) Test(org.junit.Test)

Aggregations

CalendarAstronomer (android.icu.impl.CalendarAstronomer)3 Equatorial (android.icu.impl.CalendarAstronomer.Equatorial)3 Test (org.junit.Test)3 GregorianCalendar (android.icu.util.GregorianCalendar)2 SimpleTimeZone (android.icu.util.SimpleTimeZone)2