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

Example showing how to create Lissajous profile scans.

#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 = 0;
int Ncp = 0; /* The number of generated self-intersection cross points */
/*********************************** path generation **********************************/
// LabView friendly implementation
double *xydata = NULL;
ndata = gwyscan_create_path_lissajous(NULL, 1, 1, 20, 20, 1, 1, M_PI_4, &Ncp);
xydata = malloc(2*ndata * sizeof(double));
gwyscan_create_path_lissajous(xydata, 1, 1, 20, 20, 1, 1, M_PI_4, &Ncp);
FILE* fp = fopen("scan_path_lissajous.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]);
printf("Ncp = %d \n", Ncp);
fclose(fp);
free(xydata);
return 0;
}