aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/map/libmap/trapezoidal.c
blob: 977cf60c43780e2153a574f97b00c80889b46667 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <u.h>
#include <libc.h>
#include "map.h"

static struct coord stdpar0, stdpar1;
static double k;
static double yeq;

static int
Xtrapezoidal(struct place *place, double *x, double *y)
{
	*y = yeq + place->nlat.l;
	*x = *y*k*place->wlon.l;
	return 1;
}

proj
trapezoidal(double par0, double par1)
{
	if(fabs(fabs(par0)-fabs(par1))<.1)
		return rectangular(par0);
	deg2rad(par0,&stdpar0);
	deg2rad(par1,&stdpar1);
	if(fabs(par1-par0) < .1)
		k = stdpar1.s;
	else
		k = (stdpar1.c-stdpar0.c)/(stdpar0.l-stdpar1.l);
	yeq = -stdpar1.l - stdpar1.c/k;
	return Xtrapezoidal;
}