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

Example showing how to create a simple scan path, based on regular matrix of points. This is a model function for further non-equidistant path creation; so this function itself does not do anything that one could not do manually. Function decides how many points will be necessary (here only on basis of requested x and y resolution), allocates arrays of doubles for storing the locations which microscope should follow and fills the arrays with requested values.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include "lib/gwyscan.h"
int main()
{
int i;
int ndata;
/*********************************** path generation **********************************/
// LabView friendly implementation
double *xydata;
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));
// ndata = lgs_create_regular_scan_path_pixels(NULL, 100, 100, 1, 1, 10, 10, 0, LGS_DIRECTION_FORWARD);
// xydata = malloc(2 * ndata * sizeof(double));
// lgs_create_regular_scan_path_pixels(xydata, 100, 100, 1, 1, 10, 10, 0, LGS_DIRECTION_FORWARD);
FILE* fp = fopen("scan_path_regular.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);
free(xydata);
return 0;
}