Skip to content
Snippets Groups Projects
Commit 35d4123c authored by Victor Perszel's avatar Victor Perszel :top:
Browse files

Missing includes added, function velocity created and added to main with velocity

parent 88385fcc
No related branches found
No related tags found
No related merge requests found
#include <stdio.h> #include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define L 0.15 #define L 0.15
// L = Distancia centro da roda - eixo em cm // L = Distancia centro da roda - eixo em cm
...@@ -16,12 +18,17 @@ typedef struct { ...@@ -16,12 +18,17 @@ typedef struct {
double theta; double theta;
} Robot; } Robot;
double menorDistancia (int xa, int ya, int xb,int yb){ double velocity(double dist, double tempo){
return (dist / tempo);
}
double distance(int xa, int ya, int xb,int yb){
return (sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya))); return (sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya)));
} }
int main(int argc, char const *argv[]) { int main(int argc, char const *argv[]) {
int t_size; int t_size;
double velocidade, distancia;
Tuple *tuplas; Tuple *tuplas;
Robot r = {0, 0, 0}; Robot r = {0, 0, 0};
puts("Quantos pontos há na lista? Mínimo de 10 elementos."); puts("Quantos pontos há na lista? Mínimo de 10 elementos.");
...@@ -46,6 +53,8 @@ int main(int argc, char const *argv[]) { ...@@ -46,6 +53,8 @@ int main(int argc, char const *argv[]) {
// pega o ângulo entre a posição do robô e o próximo ponto // pega o ângulo entre a posição do robô e o próximo ponto
// gira o robô // gira o robô
// calcula a velocidade para as rodas // calcula a velocidade para as rodas
distancia = distance(r.x, r.y, tuplas[i].x, tuplas[i].y);
velocidade = velocity(distancia, tuplas[i].t);
} }
// gerar tabela e grafico // gerar tabela e grafico
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment