aboutsummaryrefslogblamecommitdiffstats
path: root/libtellurian_sea_level.c
blob: 03893e248bdef83ba25da5d57378d266983b343b (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11

                                                         
            







                                                        





























                                                                                       
/* See LICENSE file for copyright and license details. */
#include "common.h"
#ifndef TEST


double
libtellurian_sea_level(double latitude)
{
	latitude = radians(latitude);
	return libtellurian_sea_level_radians(latitude);
}


#else


static int
approx(double a, double b)
{
        return fabs(a - b) <= 1e-8 * (0.5 * (a + b));
}

int
main(void)
{
	ASSERT(libtellurian_sea_level(0) == libtellurian_sea_level_radians(0));
	ASSERT(approx(libtellurian_sea_level(180), libtellurian_sea_level_radians(0)));
	ASSERT(approx(libtellurian_sea_level(360), libtellurian_sea_level_radians(0)));
	ASSERT(approx(libtellurian_sea_level(90), libtellurian_sea_level(-90)));
	ASSERT(approx(libtellurian_sea_level(90), libtellurian_sea_level(270)));
	ASSERT(approx(libtellurian_sea_level(45), libtellurian_sea_level(-45)));
	ASSERT(approx(libtellurian_sea_level(135), libtellurian_sea_level(45)));
	ASSERT(approx(libtellurian_sea_level(-135), libtellurian_sea_level(135)));
	ASSERT(libtellurian_sea_level(90) == libtellurian_sea_level_radians(D90));
	ASSERT(libtellurian_sea_level(45) == libtellurian_sea_level_radians(D45));
	ASSERT(libtellurian_sea_level(30) == libtellurian_sea_level_radians(D30));
	return 0;
}


#endif