/*
  simpletestvv.c: simple test program for vv class
*/


#include <stdio.h>
#include <stdlib.h>

#include "vector2.h"
#include "vv.h"


int main( void )
{
	Vector2 origin = new_Vector2( 0, 0 ); // Vector2 in Vector2
	Vector2 a      = new_VV( 10, 0 );     // VV in Vector2
	VV      b      = new_VV( 0, 10 );     // VV in VV

	printf( "origin isa %8s stored in a Vector2, value ", origin->isa );
	OM0(origin,print);
	printf( "\na      isa %8s stored in a Vector2, value ", a->isa );
	OM0(a,print);
	printf( "\nb      isa %8s stored in a VV,      value ", b->isa );
	OM0(b,print);
	printf( "\n\n" );

	// d = origin->magnitude, using OM0 (object-method-call) helper
	double d     = OM0(origin,magnitude);
	printf( "magnitude of " );
	OM0(origin,print);
	printf( " is %g\n", d );

	// d = origin->distance_to(a),
	// using OM1 (object-method-params-call) helper
	d     = OM1(origin,distance_to,a);
	printf( "distance from " );
	OM0(origin,print);
	printf( " to " );
	OM0(a,print);
	printf( " is %g\n", d );

	// d = a->magnitude() using OM0 (object-method-call) helper
	d = OM0(a,magnitude);
	printf( "magnitude of " );
	OM0(a,print);
	printf( " is %g\n", d );

	// d = a->distance_to(a),
	//     using OM1 (object-method-1param-call) helper
	d = OM1(a,distance_to,a);

	printf( "distance from " );
	OM0(a,print);                       // a->print()
	printf( " to itself is %g\n", d );

	// d = a->distance_to(b), using OM1 helper
	d     = OM1(a,distance_to,b);

	printf( "distance from " );
	OM0(a,print);                       // a->print()
	printf( " to " );
	OM0(b,print);                       // b->print()
	printf( " is %g\n", d );

	printf( "normalizing a: " );
	OM0(a,print);
	OM0(a,normalize);
	d = OM0(a,magnitude);
	printf( " gives " );
	OM0(a,print);
	printf( " with magnitude %g\n", d );

	printf( "scaling a: " );
	OM0(a,print);
	printf( " by 5 " );
	OM1(a,scale,5);
	printf( " gives " );
	OM0(a,print);
	d = OM0(a,magnitude);
	printf( " with magnitude %g\n", d );

	printf( "adding b: " );
	OM0(b,print);
	printf( " to a: " );
	OM0(a,print);
	OM1(a,add,b);
	printf( " gives " );
	OM0(a,print);
	d = OM0(a,magnitude);
	printf( " with magnitude %g\n", d );

	OM0( b, dispose );
	OM0( a, dispose );
	OM0( origin, dispose );
	exit(0);
	return 0;
}
