#include "../h/rccl.h"

extern int completed;

real Y = 0.;

pumatask()
{
	TRSF_PTR z, e, circ, tilt, or, fl, b1, b2, conv1, conv2;
	POS_PTR  pm1, pm2, pm3, pm4, pf, p0, p1, p2;
	int conv1fn(), conv2fn();
	int circfn(), tiltfn();
	int i;

	circ = newtrans("CONV", circfn);
	tilt = newtrans("TILT", tiltfn);
	conv1 = newtrans("CONV1",conv1fn);
	conv2 = newtrans("CONV2",conv2fn);
	z = gentr_rot("Z",  0.,  0., 864., zunit, 0.); /* at the base */
	e = gentr_eul("E" , 0. , 0. , 170. , 0. , 0.,  0.);
	or = gentr_eul("OR", 300. ,  600., 600.,    0., 0., 90.);
	fl = gentr_rot("FL", 0. , 0., 0., yunit, 180.);
	b1 = gentr_rot("B1", 600. , -300., 500., yunit, 180.);
	b2 = gentr_rot("B2", 600. , 500., 500., yunit, 180.);

	pm1 = makeposition("PM1" , z, t6, e, EQ, or, tilt, circ, fl, TL, e);
	pm2 = makeposition("PM2" , z, t6, e, EQ, or, circ, tilt, fl, TL, e);
	pm3 = makeposition("PM3" , z, t6, e, EQ, tilt, or, fl, TL, e);
	pm4 = makeposition("PM4" , z, t6, e, EQ, circ, or, fl, TL, e);
	pf = makeposition("PF" , z, t6, e, EQ, or, fl, TL, e);
	p0 = makeposition("P0" , z, t6, e, EQ, b1, TL, e);
	p1 = makeposition("P1", z, t6, e, EQ, conv1, b1, TL, e);
	p2 = makeposition("P2", z, t6, e, EQ, conv2, b1, TL, e);

	movecart(p0, 200, 1500);
	movecart(p1, 200, 3000);
	movecart(pf, 200, 1500);
	movecart(pm4, 200, 3000);
	movecart(p2, 200, 3000);
	movecart(pf, 200, 1500);
	movecart(pm3, 200, 3000);
	movecart(pm2, 200, 3000);
	movecart(pm1, 200, 3000);
	movecart(park, 200, 1500);
}



circfn(t)
TRSF_PTR t;
{
	double radius = 50.;
	t->p.y = radius * sin(2. * goalpos->scal * PIT2);
	t->p.z = radius * cos(2. * goalpos->scal * PIT2);
}


tiltfn(t)
TRSF_PTR t;
{
	VECT k;

	k.x = sin(2. * goalpos->scal * PIT2);
	k.y = cos(2. * goalpos->scal * PIT2);
	k.z = 0.;
	rot(t, &k, 5.);
}


conv1fn(t)
TRSF_PTR t;
{
	t->p.y = (Y += 6.);
}


conv2fn(t)
TRSF_PTR t;
{
	t->p.y = (Y -= 6.);
}
