fix: Change file names; Fix interpolateLine

This commit is contained in:
Frederik Beimgraben 2025-01-11 16:37:30 +01:00
parent 1b9f5bbaf8
commit ff1e7fc10d
6 changed files with 44 additions and 5 deletions

4
.gitignore vendored
View File

@ -52,4 +52,6 @@ Module.symvers
Mkfile.old Mkfile.old
dkms.conf dkms.conf
main main
result.txt

View File

@ -11,7 +11,7 @@
* https://git.beimgraben.net/MMS-2024-25/MMS-Loesung-2024-25.git * https://git.beimgraben.net/MMS-2024-25/MMS-Loesung-2024-25.git
*/ */
#include "MMS24_25.h" #include "MMS24-25.h"
#include "math.h" #include "math.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -31,10 +31,8 @@ double interpolateLine(
double dXq double dXq
) { ) {
double y = ( double y = (
(dY2 - dY1) / (dY2 - dX1)
) * dXq - (
(dY2 - dY1) / (dX2 - dX1) (dY2 - dY1) / (dX2 - dX1)
) * dX1 + dY1; ) * (dXq + dX1);
#ifdef _DEBUG_ #ifdef _DEBUG_
// DEBUG: print the parameters and result // DEBUG: print the parameters and result

8
Makefile Normal file
View File

@ -0,0 +1,8 @@
CC=gcc
SOURCE_FILE=MMS24-25.c
OPTS=-lm
all: testInterpolation
testInterpolation:
$(CC) testInterpolation.c $(SOURCE_FILE) -o testInterpolation $(OPTS)

BIN
testInterpolation Executable file

Binary file not shown.

31
testInterpolation.c Normal file
View File

@ -0,0 +1,31 @@
//
// Created by frederik on 1/11/25.
//
#include "MMS24-25.h"
#include <stdio.h>
#include <stdlib.h>
int main (int iArgC, char** ppcArgV){
int iRes = -1;
if (iArgC != 6){
printf("Number of Arguments != 6\n");
printf("Usage testInterpolation <dX1> <dY1> <dX2> <dY2> <dX>\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;
}