Gwyscan Library
 All Files Functions Enumerations Enumerator Modules
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>
#include <math.h>
#include "lib/gwyscan.h"
int main()
{
int i;
int ndata;
/*********************************** path generation **********************************/
// LabView friendly implementation
double *xydata;
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.txt", "wt");
if (fp == NULL)
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;
}