You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.3 KiB
C

#include <stdio.h>
#include <sys/time.h>
#include "SDL2/SDL.h"
struct timeval tv;
typedef struct
{
float x;
float y;
float theta;
} Vecteur;
// typedef struct {Vecteur position; Vecteur vitesse; char[25] nom} Robot;
void print_nl()
{
printf("\n");
}
void print_vecteur(Vecteur vec)
{
printf("(%f;%f;%f)", vec.x, vec.y, vec.theta);
}
Vecteur addition_vecteur(Vecteur vect1, Vecteur vect2)
{
Vecteur vecteur_somme = {vect1.x + vect2.y, vect1.y + vect2.y, vect1.theta + vect2.theta};
return vecteur_somme;
}
int main(int argc, char **argv)
{
Vecteur A = {1, 2, 3};
Vecteur B = {1, 0, 3};
Vecteur C;
C = addition_vecteur(A, B);
/*int i = 0;
unsigned long long last_tic = 0;
while (i <= 1000)
{
gettimeofday(&tv, NULL);
unsigned long long millisecondsSinceEpoch = (unsigned long long)(tv.tv_sec) * 1000 + (unsigned long long)(tv.tv_usec) / 1000;
if ((millisecondsSinceEpoch - last_tic) >= 10)
{
printf("%llu\n", millisecondsSinceEpoch);
last_tic = millisecondsSinceEpoch;
i++;
}
}*/
print_vecteur(A);
print_nl();
print_vecteur(B);
print_nl();
print_vecteur(C);
print_nl();
C.x = -10;
print_vecteur(C);
print_nl();
return 0;
}