aboutsummaryrefslogtreecommitdiff
path: root/example.c
blob: af16110e55cd03817f2ec564d35273cf005a2b89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <math.h>
#include <stdio.h>

#define PI 3.141592653

#include "gragl.h"

Scalar sin_scalar(double x) {
	Scalar y = {
		.v = sin(x),
		.valid = 1
	};

	return y;
}

Scalar cos_scalar(double x) {
	Scalar y = {
		.v = cos(x),
		.valid = 1
	};

	return y;
}

Scalar tan_scalar(double x) {
	Scalar y = {
		.v = tan(x),
		.valid = 1
	};

	return y;
}

Scalar sincos_scalar(double x) {
	Scalar y = {
		.v = sin(x) * cos(x) * cos(x) * cos(x) * x,
		.valid = 1
	};

	return y;
}

int main() {
	Plot2d sin_plot;
	sin_plot.func = sin_scalar;
	sin_plot.from = -1;
	sin_plot.to = 5;
	sin_plot.step = 0.001;

	Plot2d cos_plot;
	cos_plot.func = cos_scalar;
	cos_plot.from = -1;
	cos_plot.to = 5;
	cos_plot.step = 0.001;

	Plot2d tan_plot;
	tan_plot.func = tan_scalar;
	tan_plot.from = -1;
	tan_plot.to = 5;
	tan_plot.step = 0.001;

	Plot2d sincos_plot;
	sincos_plot.func = sincos_scalar;
	sincos_plot.from = 0;
	sincos_plot.to = 100;
	sincos_plot.step = 0.01;

	Plot2dGroup * group = create_plot2d_group(4, sin_plot, cos_plot, tan_plot, sincos_plot);
	plot(group);
	free_plot2d_group(group);

	return 0;
}