diff --git a/.gitignore b/.gitignore index 6065ccf..254bdcf 100644 --- a/.gitignore +++ b/.gitignore @@ -52,4 +52,6 @@ Module.symvers Mkfile.old dkms.conf -main \ No newline at end of file +main + +result.txt \ No newline at end of file diff --git a/MMS24_25.c b/MMS24-25.c similarity index 96% rename from MMS24_25.c rename to MMS24-25.c index 4c339b4..e210532 100644 --- a/MMS24_25.c +++ b/MMS24-25.c @@ -11,7 +11,7 @@ * https://git.beimgraben.net/MMS-2024-25/MMS-Loesung-2024-25.git */ -#include "MMS24_25.h" +#include "MMS24-25.h" #include "math.h" #include #include @@ -31,10 +31,8 @@ double interpolateLine( double dXq ) { double y = ( - (dY2 - dY1) / (dY2 - dX1) - ) * dXq - ( (dY2 - dY1) / (dX2 - dX1) - ) * dX1 + dY1; + ) * (dXq + dX1); #ifdef _DEBUG_ // DEBUG: print the parameters and result diff --git a/MMS24_25.h b/MMS24-25.h similarity index 100% rename from MMS24_25.h rename to MMS24-25.h diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5da918e --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +CC=gcc +SOURCE_FILE=MMS24-25.c +OPTS=-lm + +all: testInterpolation + +testInterpolation: + $(CC) testInterpolation.c $(SOURCE_FILE) -o testInterpolation $(OPTS) \ No newline at end of file diff --git a/testInterpolation b/testInterpolation new file mode 100755 index 0000000..46d1250 Binary files /dev/null and b/testInterpolation differ diff --git a/testInterpolation.c b/testInterpolation.c new file mode 100644 index 0000000..5512a41 --- /dev/null +++ b/testInterpolation.c @@ -0,0 +1,31 @@ +// +// Created by frederik on 1/11/25. +// + +#include "MMS24-25.h" +#include +#include + + +int main (int iArgC, char** ppcArgV){ + int iRes = -1; + + if (iArgC != 6){ + printf("Number of Arguments != 6\n"); + printf("Usage testInterpolation \n"); + exit(iRes); + }; + + double dX1 = atof(ppcArgV[1]); + double dY1 = atof(ppcArgV[2]); + double dX2 = atof(ppcArgV[3]); + double dY2 = atof(ppcArgV[4]); + double dX = atof(ppcArgV[5]); + + for(int i=0; i<4; i++){ + double dRes = interpolateLine(dX1, dY1, dX2, dY2, dX+(double)i); + printf ("%f,%f\n",dX+(double)i,dRes); + } + + return iRes; +}