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

Example showing how to create spiral centered at the origin. Spiral scans are used to reduce imperfections in scanner path as no triangular voltage is needed to be input on piezo.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include "lib/gwyscan.h"
int
main(void)
{
int i, n = 1000;
double xreal = 1e-6, yreal = 1e-6;
/* Create spiral centered at the origin with 1000 points. */
int ndata = gwyscan_create_path_spiral(NULL, n,
xreal, yreal,
-0.5*xreal, -0.5*yreal);
double *xydata = malloc(2*ndata*sizeof(double));
xreal, yreal,
-0.5*xreal, -0.5*yreal);
FILE *fp = fopen("scan_path_spiral.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;
}