#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 l(grc, grc+vector2(1,-2), matrix22(1.1, 0.2, -0.1, 0.92));

 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);

 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);

 int i;
 vector2 x = grc;
 nltransform w = nltransform::identity();
 for(i=0;i<300;i++)	{
	C vector2 wx = w(grc);
	if(round(x(0))==round(wx(0))  &&  round(x(1))==round(wx(1)))
 		GrPlot(round(x(0)), round(x(1)), 3);
	else	{
 		GrPlot(round(x(0)), round(x(1)), 1);
 		GrPlot(round(wx(0)), round(wx(1)), 2);
		}
	w = nl(w);
	x = nl(x);
 	}
 getkey();

 GrSetMode(GR_default_text);
}
