static int
oog_encode(double u, double v)
{
	static int	oog_table[NANGLES];
	static int	initialized = 0;
	register int	i;
	if (!initialized) {
		double	eps[NANGLES], ua, va, ang, epsa;
		int	ui, vi, ustep;
		for (i = NANGLES; i--; )
			eps[i] = 2.;
		for (vi = UV_NVS; vi--; ) {
			va = UV_VSTART + (vi+.5)*UV_SQSIZ;
			ustep = uv_row[vi].nus-1;
			if (vi == UV_NVS-1 || vi == 0 || ustep <= 0)
				ustep = 1;
			for (ui = uv_row[vi].nus-1; ui >= 0; ui -= ustep) {
				ua = uv_row[vi].ustart + (ui+.5)*UV_SQSIZ;
				ang = uv2ang(ua, va);
				i = (int) ang;
				epsa = fabs(ang - (i+.5));
				if (epsa < eps[i]) {
					oog_table[i] = uv_row[vi].ncum + ui;
					eps[i] = epsa;
				}
			}
		}
		for (i = NANGLES; i--; )
			if (eps[i] > 1.5) {
				int	i1, i2;
				for (i1 = 1; i1 < NANGLES/2; i1++)
					if (eps[(i+i1)%NANGLES] < 1.5)
						break;
				for (i2 = 1; i2 < NANGLES/2; i2++)
					if (eps[(i+NANGLES-i2)%NANGLES] < 1.5)
						break;
				if (i1 < i2)
					oog_table[i] =
						oog_table[(i+i1)%NANGLES];
				else
					oog_table[i] =
						oog_table[(i+NANGLES-i2)%NANGLES];
			}
		initialized = 1;
	}
	i = (int) uv2ang(u, v);
	return (oog_table[i]);
}
['static int\noog_encode(double u, double v)\n{\n\tstatic int\toog_table[NANGLES];\n\tstatic int\tinitialized = 0;\n\tregister int\ti;\n\tif (!initialized) {\n\t\tdouble\teps[NANGLES], ua, va, ang, epsa;\n\t\tint\tui, vi, ustep;\n\t\tfor (i = NANGLES; i--; )\n\t\t\teps[i] = 2.;\n\t\tfor (vi = UV_NVS; vi--; ) {\n\t\t\tva = UV_VSTART + (vi+.5)*UV_SQSIZ;\n\t\t\tustep = uv_row[vi].nus-1;\n\t\t\tif (vi == UV_NVS-1 || vi == 0 || ustep <= 0)\n\t\t\t\tustep = 1;\n\t\t\tfor (ui = uv_row[vi].nus-1; ui >= 0; ui -= ustep) {\n\t\t\t\tua = uv_row[vi].ustart + (ui+.5)*UV_SQSIZ;\n\t\t\t\tang = uv2ang(ua, va);\n\t\t\t\ti = (int) ang;\n\t\t\t\tepsa = fabs(ang - (i+.5));\n\t\t\t\tif (epsa < eps[i]) {\n\t\t\t\t\toog_table[i] = uv_row[vi].ncum + ui;\n\t\t\t\t\teps[i] = epsa;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (i = NANGLES; i--; )\n\t\t\tif (eps[i] > 1.5) {\n\t\t\t\tint\ti1, i2;\n\t\t\t\tfor (i1 = 1; i1 < NANGLES/2; i1++)\n\t\t\t\t\tif (eps[(i+i1)%NANGLES] < 1.5)\n\t\t\t\t\t\tbreak;\n\t\t\t\tfor (i2 = 1; i2 < NANGLES/2; i2++)\n\t\t\t\t\tif (eps[(i+NANGLES-i2)%NANGLES] < 1.5)\n\t\t\t\t\t\tbreak;\n\t\t\t\tif (i1 < i2)\n\t\t\t\t\toog_table[i] =\n\t\t\t\t\t\toog_table[(i+i1)%NANGLES];\n\t\t\t\telse\n\t\t\t\t\toog_table[i] =\n\t\t\t\t\t\toog_table[(i+NANGLES-i2)%NANGLES];\n\t\t\t}\n\t\tinitialized = 1;\n\t}\n\ti = (int) uv2ang(u, v);\n\treturn (oog_table[i]);\n}']