--- /dev/null
+/*
+ * homogen.c - bewegung im homogenen feld f=g(0,-1)
+ *
+ * usage: ./homogen <x_0> <y_0> <vx_0> <vy_o> <steps> <g> <alpha>
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+#include <stdlib.h>
+#include "g_plot.h"
+
+int main(int argc,char **argv) {
+ double x,x_p,y,y_p,vx,vx_p,vy,vy_p;
+ double g,alpha,f_x,f_y,tau;
+ int i,steps;
+ int fd; /* data file */
+ double buf[5];
+ char filename[64];
+
+ if(argc!=8) {
+ printf("usage: %s <x_0> <y_0> <vx_0> <vy_0> <steps> <g> <alpha>\n",argv[0]);
+ return -1;
+ }
+
+ /* init + starting conditions */
+ x_p=atof(argv[1]); y_p=atof(argv[2]);
+ vx_p=atof(argv[3]); vy_p=atof(argv[4]);
+ steps=atoi(argv[5]); g=atof(argv[6]); alpha=atof(argv[7]);
+ tau=2*M_PI/steps;
+ sprintf(filename,"homogen_%f_%f_%f_%f_%d_%f_%f.plot",x_p,y_p,vx_p,vy_p,steps,g,alpha);
+ fd=gp_init(filename);
+
+ buf[0]=0;
+ buf[1]=x_p; buf[2]=y_p;
+ buf[3]=vx_p; buf[4]=vy_p;
+ gp_add_data(fd,buf,5,1,TYPE_DOUBLE);
+
+ /* loop */
+ for(i=0;;i++) {
+ f_x=-alpha*vx_p; f_y=-g-alpha*vy_p;
+ x=x_p+vx_p*tau; y=y_p+vy_p*tau;
+ vx=vx_p+f_x*tau; vy=vy_p+f_y*tau;
+ /* save data */
+ buf[0]=i*tau;
+ buf[1]=x; buf[2]=y;
+ buf[3]=vx; buf[4]=vy;
+ gp_add_data(fd,buf,5,1,TYPE_DOUBLE);
+ /* switch */
+ x_p=x; y_p=y;
+ vx_p=vx; vy_p=vy;
+ /* stop at y~0 ! */
+ if((y<=0)&&(i!=0)) break;
+ }
+
+ printf("reached ground at step %d\n",i);
+
+ /* close file */
+ gp_close(fd);
+
+ return 1;
+}