PageRenderTime 21ms CodeModel.GetById 12ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/Proj4/pj_deriv.c

http://github.com/route-me/route-me
C | 36 lines | 34 code | 1 blank | 1 comment | 10 complexity | f621de6882d1b00b0f3928c4e4f7e71e MD5 | raw file
 1/* dervative of (*P->fwd) projection */
 2#ifndef lint
 3static const char SCCSID[]="@(#)pj_deriv.c	4.4	93/06/12	GIE	REL";
 4#endif
 5#define PJ_LIB__
 6#include "projects.h"
 7	int
 8pj_deriv(LP lp, double h, PJ *P, struct DERIVS *der) {
 9	XY t;
10
11	lp.lam += h;
12	lp.phi += h;
13	if (fabs(lp.phi) > HALFPI) return 1;
14	h += h;
15	t = (*P->fwd)(lp, P);
16	if (t.x == HUGE_VAL) return 1;
17	der->x_l = t.x; der->y_p = t.y; der->x_p = -t.x; der->y_l = -t.y;
18	lp.phi -= h;
19	if (fabs(lp.phi) > HALFPI) return 1;
20	t = (*P->fwd)(lp, P);
21	if (t.x == HUGE_VAL) return 1;
22	der->x_l += t.x; der->y_p -= t.y; der->x_p += t.x; der->y_l -= t.y;
23	lp.lam -= h;
24	t = (*P->fwd)(lp, P);
25	if (t.x == HUGE_VAL) return 1;
26	der->x_l -= t.x; der->y_p -= t.y; der->x_p += t.x; der->y_l += t.y;
27	lp.phi += h;
28	t = (*P->fwd)(lp, P);
29	if (t.x == HUGE_VAL) return 1;
30	der->x_l -= t.x; der->y_p += t.y; der->x_p -= t.x; der->y_l += t.y;
31	der->x_l /= (h += h);
32	der->y_p /= h;
33	der->x_p /= h;
34	der->y_l /= h;
35	return 0;
36}