Created
May 20, 2011 13:05
-
-
Save kventil/982850 to your computer and use it in GitHub Desktop.
Elsa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdarg.h> | |
#include <math.h> | |
#include <stdlib.h> | |
#define MESSPUNKTE 320 | |
#define UMDREHUNGEN 10 | |
double radius = 0.012; // 12 mm | |
double pleul = 0.077; // 77 mm | |
double m = 0.075; //m=75g ramm | |
double c = 2.5; //2,5 NewtonMeter | |
double d = 0.05; | |
/*Gibt die Position des Pleulendes zurück*/ | |
double x(int tick) | |
{ | |
double phi_deg = tick*11.25*M_PI/180; | |
return ((radius * cos(phi_deg))+ pleul * pow((radius/pleul),2)*pow(sin(phi_deg),2)))); | |
} | |
/*Gibt die Position der Kuh zurück*/ | |
double y(int tick,double intervall,double yn1,double yn2) | |
{ | |
double delta_t = intervall; | |
return ((c*x(tick)+(d*(yn1+x(tick)-x(tick-1))/delta_t)+(m*(((2*yn1)-yn2)/(delta_t*delta_t)))))/ | |
(c+(d/delta_t)+(m/(delta_t*delta_t))); | |
} | |
int main (int argc, char const *argv[]) | |
{ | |
double intervall; | |
if(argc <= 1) | |
{ | |
printf("Kein Parameter U/min übergeben!\nProgramm beendet.\n"); | |
printf("Benutzung: %s 19\n",argv[0]); | |
return 1; | |
} | |
double upm = atof(argv[1]); | |
printf("Upm:\t %f\n",upm); | |
intervall = UMDREHUNGEN/upm*60/MESSPUNKTE; | |
printf("sec/messpunkte:\t %f\n",intervall); | |
int i; | |
double time = 0.0; | |
double yn1 = 0.0; | |
double yn2 = 0.0; | |
printf("i\tt (in sec)\tx (in mm)\n"); | |
printf("---------------------------------------\n"); | |
for(i = 0; i < MESSPUNKTE+1; ++i) | |
{ | |
yn1 = y(i,intervall,yn1,yn2); | |
printf("%i\t%f\t%f\t%f\n",i,time,x(i),yn1); | |
time = time + intervall; | |
yn2 = yn1; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment