Example showing how to revert points in existing path.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
int main()
{
int i;
int ndata;
double *xydata, *xydata_revert;
xydata = malloc(2*ndata * sizeof(double));
xydata_revert = malloc(2*ndata * sizeof(double));
FILE* fp = fopen("scan_path_revert_in.txt", "wt");
if (fp == NULL) {
printf("Error. Unable to open file for writing %s \n", strerror(errno));
return 0;
}
for (i = 0; i < ndata; i++)
fprintf(fp, "%d %g %g\n", i, xydata[2*i], xydata[2*i + 1]);
fclose(fp);
fp = fopen("scan_path_revert_out.txt", "wt");
if (fp == NULL) {
printf("Error. Unable to open file for writing %s \n", strerror(errno));
return 0;
}
for (i = 0; i < ndata; i++)
fprintf(fp, "%d %g %g\n", i, xydata_revert[2*i], xydata_revert[2*i + 1]);
fclose(fp);
free(xydata);
free(xydata_revert);
return 0;
}