#include "../nltrans.h"
#include <graphics.h>
#include <math.h>
#include <mylib.h>
#include <std.h>



main(int argc, char **argv)
{
 C double n1 = argc>0 ? atof(*(argc--,argv++)) : 0.0;
 C double n2 = argc>0 ? atof(*(argc--,argv++)) : 0.0;
 C double n3 = argc>0 ? atof(*(argc--,argv++)) : 0.0;
 C double n4 = argc>0 ? atof(*(argc--,argv++)) : 0.0;
 C double n5 = argc>0 ? atof(*(argc--,argv++)) : 0.0;
 C double n6 = argc>0 ? atof(*(argc--,argv++)) : 0.0;

 printf("%g %g %g %g %g %g\n", n1, n2, n3, n4, n5, n6);
 GrSetMode(GR_default_graphics);

 C vector2 grc(0.5*GrMaxX(), 0.5*GrMaxY());
 C ltransform l0(grc, grc+vector2(-13,-2), matrix22(1., 0.1, -0.3, 1.14));
 C ltransform l(grc, grc+vector2(10,-20), matrix22(1.1, 0.2, -0.1, 0.9));

 C nltransform nl(tensor222(0+n1+n3+n5+n6, 0+n2/2+n4/2,
 								0+n2/2+n4/2, 0+n1+n3-n5-n6,
 								0+n1-n3+n5-n6, 0+n2/2-n4/2,
								0+n2/2-n4/2, 0+n1-n3-n5+n6),
 						l,
 						grc);

 C nltransform nl0 = nl(l0);

 GrSetColor(1, 200, 100, 0);
 GrSetColor(2, 0, 100, 200);
 GrSetColor(3, 100, 100, 100);
 GrSetColor(4, 200, 0, 200);
 GrSetColor(0, 0, 0, 0);
 GrPlot(round(grc(0)), round(grc(1)), 4);
 GrPlot(round(grc(0))+1, round(grc(1)), 4);
 GrPlot(round(grc(0)), round(grc(1))+1, 4);
 GrPlot(round(grc(0))-1, round(grc(1)), 4);
 GrPlot(round(grc(0)), round(grc(1))-1, 4);

 int x;
 for(x=0;x<GrMaxX();x++)	{
	int y;
	for(y=0;y<GrMaxY();y++)
		if(x%20==0 || y%20==0)	{

			C vector2 tmp(x, y);

			C vector2 llt = l0(tmp);
			C vector2 ltmp = nl(llt);
			C vector2 nltmp = nl0(tmp);

			{
			C int nlx = round(nltmp(0));
			C int nly = round(nltmp(1));
			C int c = GrPixel(nlx, nly);
			if(c != 2)
				GrPlot(nlx, nly, c==0 ? 2 : 3);
			}
			{
			C int lx = round(ltmp(0));
			C int ly = round(ltmp(1));
			C int c = GrPixel(lx, ly);
			if(c != 1)
				GrPlot(lx, ly, c==0 ? 1 : 3);
			}
			}
 	}
 getkey();

 GrSetMode(GR_default_text);
}
