aboutsummaryrefslogtreecommitdiffstats
path: root/libtellurian_gaussian_radius_radians.c
blob: d61319a3918c1db9b540c7f702a6571723bb0016 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/* See LICENSE file for copyright and license details. */
#include "common.h"


double
libtellurian_gaussian_radius_radians(double latitude)
{
	double a = LIBTELLURIAN_EQUATORIAL_RADIUS;
	double b = LIBTELLURIAN_POLAR_RADIUS;
	double f = 1.0 - b / a;
	double neg_e2 = (f - 2.0) * f;
	double neg_e2_plus_1 = fma(f - 2.0, f, 1.0);
	double s = sin(latitude);
	double denom = fma(neg_e2, s * s, 1.0);
	return a * sqrt(neg_e2_plus_1) / denom;
}