Gwyscan Library
 All Data Structures Files Functions Enumerations Enumerator Macros Groups
modify_path_flip_vertical.c

Example showing how to flip points in existing path vertically.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include "lib/gwyscan.h"
int main()
{
int i;
int ndata;
double *xydata, *xydata_fv;
/*********************************** path generation **********************************/
// LabView friendly implementation
ndata = gwyscan_create_path_regular(NULL, 20, 20, 1, 1, 10, 10, M_PI_4, GWYSCAN_DIRECTION_FORWARD_ALTERNATEBLOCK);
xydata = malloc(2*ndata * sizeof(double));
xydata_fv = malloc(2*ndata * sizeof(double));
gwyscan_modify_path_flip_vertical(xydata_fv, xydata, ndata);
FILE* fp = fopen("scan_path_flip_vertical_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_flip_vertical_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_fv[2*i], xydata_fv[2*i + 1]);
fclose(fp);
free(xydata);
free(xydata_fv);
return 0;
}