aboutsummaryrefslogblamecommitdiffstats
path: root/libtellurian_azimuthal_radius_radians.c
blob: e9433e3f2e5c6e0ecda38708f21c10a3eef30275 (plain) (tree)
1
2
3
4
5
6
7
8

                                                         
            




                                                                      


                                                               





                                                

























































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


double
libtellurian_azimuthal_radius_radians(double latitude, double azimuth)
{
	double lat = geodetic(latitude);
	double m = libtellurian_meridian_radius_radians(lat);
	double n = libtellurian_transverse_radius_radians(lat);
	double c2 = cos(azimuth) * cos(azimuth);
	double s2 = sin(azimuth) * sin(azimuth);
	double x = c2 / m;
	double y = s2 / n;
	return 1.0 / (x + y);
}


#else


static int
approx(double a, double e)
{
	double err = fabs((a / e) - 1.0);
	return err <= 1.0e-8;
}


int
main(void)
{
	ASSERT(approx(libtellurian_azimuthal_radius_radians(D90, 0), libtellurian_meridian_radius_radians(D90)));
	ASSERT(approx(libtellurian_azimuthal_radius_radians(D90, D30), libtellurian_meridian_radius_radians(D90)));
	ASSERT(approx(libtellurian_azimuthal_radius_radians(D90, D45), libtellurian_meridian_radius_radians(D90)));
	ASSERT(approx(libtellurian_azimuthal_radius_radians(D90, D60), libtellurian_meridian_radius_radians(D90)));
	ASSERT(approx(libtellurian_azimuthal_radius_radians(D90, D90), libtellurian_meridian_radius_radians(D90)));
	ASSERT(approx(libtellurian_azimuthal_radius_radians(D90, D180), libtellurian_meridian_radius_radians(D90)));
	ASSERT(approx(libtellurian_azimuthal_radius_radians(D90, -D30), libtellurian_meridian_radius_radians(D90)));
	ASSERT(approx(libtellurian_azimuthal_radius_radians(D90, -D45), libtellurian_meridian_radius_radians(D90)));
	ASSERT(approx(libtellurian_azimuthal_radius_radians(D90, -D60), libtellurian_meridian_radius_radians(D90)));
	ASSERT(approx(libtellurian_azimuthal_radius_radians(D90, -D90), libtellurian_meridian_radius_radians(D90)));
	ASSERT(approx(libtellurian_azimuthal_radius_radians(D90, -D180), libtellurian_meridian_radius_radians(D90)));

	ASSERT(approx(libtellurian_azimuthal_radius_radians(0, 0), libtellurian_meridian_radius_radians(0)));
	ASSERT(approx(libtellurian_azimuthal_radius_radians(D30, 0), libtellurian_meridian_radius_radians(D30)));
	ASSERT(approx(libtellurian_azimuthal_radius_radians(D45, 0), libtellurian_meridian_radius_radians(D45)));
	ASSERT(approx(libtellurian_azimuthal_radius_radians(D60, 0), libtellurian_meridian_radius_radians(D60)));
	ASSERT(approx(libtellurian_azimuthal_radius_radians(D180, 0), libtellurian_meridian_radius_radians(D180)));

	ASSERT(approx(libtellurian_azimuthal_radius_radians(0, D180), libtellurian_meridian_radius_radians(0)));
	ASSERT(approx(libtellurian_azimuthal_radius_radians(D30, D180), libtellurian_meridian_radius_radians(D30)));
	ASSERT(approx(libtellurian_azimuthal_radius_radians(D45, D180), libtellurian_meridian_radius_radians(D45)));
	ASSERT(approx(libtellurian_azimuthal_radius_radians(D60, D180), libtellurian_meridian_radius_radians(D60)));
	ASSERT(approx(libtellurian_azimuthal_radius_radians(D180, D180), libtellurian_meridian_radius_radians(D180)));

	ASSERT(approx(libtellurian_azimuthal_radius_radians(0, D90), libtellurian_transverse_radius_radians(0)));
	ASSERT(approx(libtellurian_azimuthal_radius_radians(D30, D90), libtellurian_transverse_radius_radians(D30)));
	ASSERT(approx(libtellurian_azimuthal_radius_radians(D45, D90), libtellurian_transverse_radius_radians(D45)));
	ASSERT(approx(libtellurian_azimuthal_radius_radians(D60, D90), libtellurian_transverse_radius_radians(D60)));
	ASSERT(approx(libtellurian_azimuthal_radius_radians(D90, D90), libtellurian_transverse_radius_radians(D90)));
	ASSERT(approx(libtellurian_azimuthal_radius_radians(D180, D90), libtellurian_transverse_radius_radians(D180)));

	ASSERT(approx(libtellurian_azimuthal_radius_radians(0, -D90), libtellurian_transverse_radius_radians(0)));
	ASSERT(approx(libtellurian_azimuthal_radius_radians(D30, -D90), libtellurian_transverse_radius_radians(D30)));
	ASSERT(approx(libtellurian_azimuthal_radius_radians(D45, -D90), libtellurian_transverse_radius_radians(D45)));
	ASSERT(approx(libtellurian_azimuthal_radius_radians(D60, -D90), libtellurian_transverse_radius_radians(D60)));
	ASSERT(approx(libtellurian_azimuthal_radius_radians(D90, -D90), libtellurian_transverse_radius_radians(D90)));
	ASSERT(approx(libtellurian_azimuthal_radius_radians(D180, -D90), libtellurian_transverse_radius_radians(D180)));
	return 0;
}


#endif