Initial commit
This commit is contained in:
138
application/source/examples/example.vector.c
Normal file
138
application/source/examples/example.vector.c
Normal file
@@ -0,0 +1,138 @@
|
||||
|
||||
|
||||
|
||||
#include "vector2.h"
|
||||
|
||||
#include "vector3.h"
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include "array.h"
|
||||
|
||||
#include "triangle.h"
|
||||
|
||||
void main() {
|
||||
|
||||
array * arrayA = new array();
|
||||
|
||||
clock_t tic = clock();
|
||||
|
||||
vector2 * testVector = new vector2( 1, 450 );
|
||||
|
||||
|
||||
int count = 0;
|
||||
|
||||
for (int i = 0; i < 1000000; ++i)
|
||||
{
|
||||
vector2 * testVector1 = new vector2( i, i * 450 );
|
||||
|
||||
vector2 * testVector2 = new vector2( 10, 450 );
|
||||
|
||||
testVector += testVector1 + testVector2;
|
||||
|
||||
count++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
printf("count: %i\n", count);
|
||||
|
||||
|
||||
for ( int i = 0; i < 1; ++i )
|
||||
{
|
||||
|
||||
vector2 testVector = new vector2( 10, 450 );
|
||||
|
||||
|
||||
arrayA->add( &testVector );
|
||||
|
||||
arrayA->add( &testVector );
|
||||
|
||||
|
||||
//printf("number of items in array: %i \n ", arrayA->length() );
|
||||
|
||||
vector2 * returned = arrayA->get( i );
|
||||
|
||||
//printf("returned vector x: %i \n ", returned->x );
|
||||
|
||||
//printf("returned vector y: %i \n ", returned->y );
|
||||
|
||||
vector2 testVector3 = new vector2( 2, 3 );
|
||||
|
||||
arrayA->set( i, &testVector3 );
|
||||
|
||||
vector2 * secondReturn = arrayA->get( 0 );
|
||||
|
||||
//printf("returned vector x: %i \n ", secondReturn->x );
|
||||
|
||||
//printf("returned vector y: %i \n ", secondReturn->y );
|
||||
|
||||
returned->add( secondReturn );
|
||||
|
||||
printf( "returned vector x: %i \n ", returned->x );
|
||||
|
||||
printf("returned vector y: %i \n ", returned->y );
|
||||
|
||||
}
|
||||
|
||||
|
||||
for ( int i = 0; i < 1; ++i )
|
||||
{
|
||||
|
||||
vector2 a = new vector2( 10, 10 );
|
||||
|
||||
vector2 b = new vector2( 10, 10 );
|
||||
|
||||
a->add( &b );
|
||||
|
||||
printf( "a->x: %i, a->y: %i\n", a.x, a.y);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (int i = 0; i < 1; ++i)
|
||||
{
|
||||
triangle * a = new triangle();
|
||||
|
||||
triangle * b = new triangle();
|
||||
|
||||
|
||||
a->add( b );
|
||||
}
|
||||
|
||||
|
||||
vector2 * t = new vector2( 2,2 );
|
||||
|
||||
int totalLength = 0;
|
||||
|
||||
for (int i = 0; i < 1; ++i)
|
||||
{
|
||||
|
||||
t->x = 100;
|
||||
|
||||
vector2 b = new vector2( 123, 2 );
|
||||
|
||||
b.x = 50;
|
||||
|
||||
vector2 c = new vector2( 1, 12 );
|
||||
|
||||
|
||||
c.x = i;
|
||||
|
||||
t->add( &b );
|
||||
|
||||
b.add( &c );
|
||||
|
||||
c.add( &b );
|
||||
|
||||
printf("a, %i\n", t->x);
|
||||
|
||||
printf("b, %i\n", b.x);
|
||||
|
||||
printf("c, %i\n", c.x);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user