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


double
libtellurian_normal_gravity_radians(double latitude)
{
	double a = LIBTELLURIAN_EQUATORIAL_RADIUS;
	double b = LIBTELLURIAN_POLAR_RADIUS;
	double neg_e2 = fma(b / a, b / a, -1.0);
	double ag = a * LIBTELLURIAN_EQUATORIAL_GRAVITY;
	double bg = b * LIBTELLURIAN_POLAR_GRAVITY;
	double k = bg / ag - 1.0;
	double sin2_phi = sin(latitude) * sin(latitude);
	double num = fma(k, sin2_phi, 1.0);
	double denom2 = fma(neg_e2, sin2_phi, 1.0);
	return LIBTELLURIAN_EQUATORIAL_GRAVITY * num / sqrt(denom2);
}