#include <gpk_std.h>
#include "../nbox.h"
#include <stdio.h>
#include <assert.h>

main()
{
 C vector_space A("A");
 C vector_space B("B");
 C vector_space unit("unit");

 C box A_area(1.0, 2.0, 3.0, 5.0, &A);
 C nltransform BtoA(vector2(0,0,&B), A_area.center(),
						matrix22(1.1, 0.1, -0.21, 0.95),
						tensor222(.01, .02, -.01, -.02, -.03, .01, .01, 0));

 C box B_area = inverse_image(A_area, BtoA);

 C ltransform unit_to_B(box::unitbox, B_area);
 double x;
 for(x=1e-5;x<1.0;x+=0.01*(1-2e-5))	{
	double y;
	for(y=1e-5;y<1.0;y+=0.01*(1-2e-5))	{
		C vector2 xy(x, y);
		assert(box::unitbox.encloses(xy));
		C vector2 Bxy(unit_to_B(xy));
		assert(B_area.encloses(Bxy));
		C vector2 Axy = BtoA(Bxy);
		assert(A_area.encloses(Axy));
		}
	}
 printf("OK\n");
}
