fix: Change file names; Fix interpolateLine
This commit is contained in:
parent
1b9f5bbaf8
commit
ff1e7fc10d
2
.gitignore
vendored
2
.gitignore
vendored
@ -53,3 +53,5 @@ Mkfile.old
|
||||
dkms.conf
|
||||
|
||||
main
|
||||
|
||||
result.txt
|
||||
@ -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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -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
|
||||
8
Makefile
Normal file
8
Makefile
Normal 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
BIN
testInterpolation
Executable file
Binary file not shown.
31
testInterpolation.c
Normal file
31
testInterpolation.c
Normal 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;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user