#include <gpk_std.h>
#include "../nline.h"
#include <math.h>
#include <stdio.h>
#include <assert.h>


main()
{
 C nline str(vector2(0,0), vector2(1,0), vector2(0,0));
 assert(!str.check_hasangle(23));
 assert(str.check_hasangle(0.0));

 C nline tr(vector2(0,0), vector2(1,0), vector2(0,1));
 assert(tr.check_hasangle(1.2));
 assert(tr.check_hasangle(0.2));
 assert(fabs(tr.p_hasangle(0.0) - 0.0) < 1e-6);
 assert(fabs(tr.p_hasangle(M_PI/4) - 0.5) < 1e-6);
 double x;
 for(x=0.001; x<1.4;x += 0.01)
 	assert(fabs(tr.angle(tr.p_hasangle(x)) - x) < 1e-6);
 assert(dist(tr(tr.p_hasangle(0))-vector2(0,0)) < 1e-6);
 assert(dist(tr(1.0) - vector2(1,1)) < 1e-6);

C nline ts = tr + vector2(1,1);
 for(x=0.001; x<1.4;x += 0.01)	{
 	assert(fabs(ts.angle(ts.p_hasangle(x)) - x) < 1e-6);
 	assert(fabs(tr.angle(ts.p_hasangle(x)) - x) < 1e-6);
 	assert(fabs(ts.angle(tr.p_hasangle(x)) - x) < 1e-6);
	assert(dist(ts(x) - (tr(x)+vector2(1,1))) < 1e-6);
	}
 printf("OK\n");
}
